Arrays / collections with literal syntax - fixed size?

Alexander Lazarevic' Alexander at Lazarevic.de
Sun Jan 6 20:54:52 UTC 2008


> Right.
>
> It's the fact that #(..) is a literal.
> And modifying a literal is a bad practice, whatever the language.
Now I was under the impression, that a context had a copy of a compiled
method with copies of the literals, so that you could only modify the
copies but not the literals in the compiled method. But it seems not to
be that way:

Play class>>test
    "5 timesRepeat: [Transcript show: Play test printString; cr]"
    | a |
    a := #(1).
    a at: 1 put: ((a at: 1) + 1).
    ^ a

This is evil! :)

Alex



More information about the Squeak-dev mailing list