[squeak-dev] Compiling {} statically?

Igor Stasenko siguctua at gmail.com
Tue Nov 24 10:09:58 UTC 2009


2009/11/24 Andreas Raab <andreas.raab at gmx.de>:
> Hi -
>
> Here is a question: Does anyone know how much effort it would be to compile
> the brace array construct down to a literal array if it only contains static
> elements? This would allow us to use {} consistently even in places where
> we'd otherwise use #(). I'm not sure if it's worth it but I dislike the
> asymmetry in literal arrays that symbols aren't prefixed by #symbol and if
> we'd be able to compile {} statically where that's possible we could
> completely and consistently replace all uses of #() by {}.
>
> Thoughts?
>

There's one thing, which still different for these two constructs,
even if all elements can be evaluated at compile time.
The {} array is constructed at run time, so one may expect that it is
mutable, while arrays defined using #() not.

I.e. things like:

myArray := #(1 3 4 2) sort.

should lead to error , while

myArray := {1. 3. 4. 2. } sort.

not.
>From this point, i think compiling {} arrays statically may lead to
unwanted behavior later, when we could have an immutable objects in
Squeak.
But of course, if we leave things as they are (no immutability), then
any literal arrays can be modified, which makes no difference between
those two, except from syntax.

> Cheers,
>  - Andreas


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list