Hi!
Jordi Delgado <
[hidden email]> wrote:
> I got to this piece of code:
>
> | f |
> f := #('a' [Transcript show: 'An a was input']).
> f := (f copyFrom: 2 to: f size).
> (Compiler evaluate: f) class
>
> Selecting and printing gives the following result:
> Squeak Image 2.5 --> BlockContext
> Squeak Image 3.9 --> Array
Well, I am surprised that 2.5 resulted in a BlockContext, AFAIK at least
from 3.2 and onwards the expression:
#('a' [Transcript show: 'An a was input'])
results in:
#('a' #[ #Transcript #show: 'An a was input' #])
An array literal does not evaluate the different bits in it, it just
assumes they are Strings or Symbols separated with spaces, even if they
do not have the hashmark in front of them.
You can use the newer syntax with {} to get the Parser to actually
evaluate the expressions, but then you need to separate using periods:
{'a'. [Transcript show: 'An a was input']}
Now... back to that code of yours, it is a serious mess. :)
| f |
f := #('a' [Transcript show: 'An a was input']). "<- as we saw this
produces an Array of Symbols in newer Squeaks"
f := (f copyFrom: 2 to: f size). "<- this actually
produces an Array, not a single element!"
(Compiler evaluate: f) class "<- the Compiler is
friendly and sends asString to its argument if it is not a String or a
Stream. And sending asString to an Array gives its literal
representation which we actually can evaluate - to an Array again :)."
So... I wonder what the 2.5 image does to end up with a BlockContext,
don't have one handy. Perhaps it does some funny stuff if the argument
to Compiler is an Array?
regards, Göran
PS. Select parts of your code and use alt-i or alt-I or simply debug it
to follow it.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners