[squeak-dev] isSelfEvaluating

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sat Oct 31 14:43:23 UTC 2009


2009/10/31 Bert Freudenberg <bert at freudenbergs.de>:
>
> On 31.10.2009, at 09:50, Stéphane Rollandin wrote:
>
>>>> If the meaning of #isLiteral is to indicate that what is printed can be
>>>> read back (i.e. will be correctly parsed) then I think it is a very useful
>>>> message that we should keep.
>>>
>>> #isLiteral mainly indicates which objects can be created at compile time.
>>> They are literally inserted in the compiled method. This must match the
>>> syntax definition of Squeak. There is no question about not keeping it.
>>
>> now I'm confused. are all objects anwering true to #isLiteral also have a
>> printed form that can be read back ? should they ?
>>
>> Stef
>
> It's the other way around - the objects that are recognized syntactically in
> a literal array #(...) must also answer true from #isLiteral. See
> Array>>isLiteral. This of course implies their printed form is recognized by
> the parser.
>
> isSelfEvaluating goes beyond literals - e.g., you cannot put a Point into a
> literal array because of syntactical restrictions, "#(3 at 4)" is parsed as
> "#(3 #@ 4)". But its print string can still be made self-evaluating as
> "{3 at 4}" which is readable. If you want to force a self-evaluating expression
> to be printed you need to use storeString
>
> In older Squeak versions like 3.8 you had this:
>
> {3 at 4} printString
>        '#(3 at 4)'
>
> But that is not self-evaluating even if to a novice it might look like it
> was, which is a source of confusion. To avoid that you would need this
>
> {3 at 4} storeString
>        '((Array new: 1) at: 1 put: 3 at 4; yourself)'
>
> which does evaluate to an object equal to the original one, but looks ugly.
> Now try the same expressions in a more recent Squeak and it's much nicer :)
>
> - Bert -
>

Hey, wait Bert, you're selling more than we have !
#isSelfEvaluating is just embellishing printString, it does nothing
for storeString...
If we want to use it for a better storeString, then we have to solve
((0 at 0 extent: 1 at 1) -> 0) printString first.

Nicolas



More information about the Squeak-dev mailing list