|
|
|
|
|
by pg314
3328 days ago
|
|
> Smalltalk OTOH uses text as source code That is not completely correct. It uses a mixture of text (strings) and objects. The class graph is composed of objects, but the method bodies are stored as objects and (optionally) strings. To edit the class graph, it presents (parts of) it as text that you can edit (see ClassDescription>>definition in Squeak). E.g. to allow you to edit the Behavior class, it generates the following string and presents it in a text editor: Behavior subclass: #ClassDescription
instanceVariableNames: 'instanceVariables organization'
classVariableNames: 'TraitImpl'
poolDictionaries: ''
category: 'Kernel-Classes'
Notice that this is a Smalltalk statement that can be evaluated. If you edit this strings and accept it, it will evaluate the code which updates the objects describing the class. The primary representation is not textual, but an object graph.A method is stored as byte code, and optionally as a string. The system will present you with a textual representation that you can edit, which is either the stored string or the decompiled byte code (which loses the original comments, indentation, and variable names). You can strip the textual representation of all methods to slim down the image (see SmalltalkImage>>abandonSources). You can also file in/out a textual representation of classes and their methods. But that is not the primary representation of the code. |
|
All changes to the class graph are also stored as changes in text. Every class has a textual representation. You can load an earlier image and replay this. This is basically like loading Lisp code into a Lisp image.
> it will evaluate the code which updates the objects describing the class.
This is like Lisp. The Lisp code manipulates the runtime class graph.
> But that is not the primary representation of the code.
The primary representation is text. That's what the IDE presents you when you edit the method.