compiling blocks

Ian Bicking bickiia at earlham.edu
Tue Apr 28 23:38:36 UTC 1998


David Farber writes:
> no, i have to create the string '[ :foo | foo bar]' on the fly. (because i
> don't know bar). i need to create this block at *run time*.

Well, you could try 

    [:foo :instruction | foo perform: instruction],

then call the block like

    thatBlock value: someObject value: #bar.

Or, if you need the possibility of multiple arguments:

    [:foo :instruction :arguments | foo perform: instruction 
                                        withArguments: arguments]

And call it like:

    theOtherBlock value: someObject 
                  value: #inject:into:
                  value: (Array with: 1 with: enumBlock).


These are a little simpler than using Compiler, but can allow a fair
amount of generality.


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|| Ian Bicking                 |  bickiia at earlham.edu ||
|| drawer #419 Earlham College |  (765) 973-2537      ||
|| Richmond, IN 47374          |                      ||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --





More information about the Squeak-dev mailing list