compiling blocks
David Farber
dfarber at numenor.com
Tue Apr 28 22:53:20 UTC 1998
>The "block := ..." statement is the code... I just sent the #value: message
>at the end for an example. You could have returned the block instead of
>evaluating it. For example,
>Integer>>foo
> | test |
> test := 5.
> ^Compiler new
> evaluate: '[:a | a + test + self]'
> in: thisContext
> to: self
> notifying: nil
> ifFail: [nil]
>will return a block content that you can then send #value: to (4 foo value:
>10 ==> 19)...
ah, yes. i was throw off by "evaluate".
>If you don't want access to variables declared outside the block, you can
>simply use:
> Compiler evaluate: '[ :foo | foo bar]'
actually, that is precisely what i wanted! thanks!!
dave
--
j. david farber
oo architect+mentor
numenor labs incorporated
in sunny boulder colorado
dfarber at numenor.com
www.numenor.com
More information about the Squeak-dev
mailing list
|