[self-interest] Re: Self for Squeak

Jecel Assumpcao Jr jecel at merlintec.com
Wed Aug 31 17:12:42 UTC 2005


David P Harris wrote on Wed, 31 Aug 2005 09:50:26 -0700
> Hey, nice!  I am confused re the use of [].... as in:
> 
> ( |
> parent* = [( |
> b = [4].
> sum = (^ a+b).
> ifTrue: b1 ifFalse: b2 = ( ^ b1 value ) | )].
> a = [3].
> | )
> 
> Are they just syntactical?

It took me a little while to figure them out too even though one of the
presentations explains them. The idea is that whatever is inside the
[...] gets compiled, evaluated and then the result is what is used in
the main compiled code. The reason we don't need this in Self is because
there is a magical rule saying "slot initialization expressions are
evaluated in the context of the lobby instead of the object being
compiled". This has no effect on the syntax but changes the semantics
significantly, though in a way that is intuitive enough that we don't
even notice it.

The advantage of an explicit mechanism instead of a magical rule is that
you get more flexibility. In Agora you use ' in front of a message name
to have it evaluated at compile time. Normal Forth also uses [...] to
switch to "interpret mode" and back while ColorForth uses different
colors (green compiles, yellow interprets).

-- Jecel



More information about the Self-interest mailing list