how do i compile '[ :foo | foo bar]' on the fly so that i can store it in an instance variable and send value: to it sometime later on?
Have a method returning this block. E.g. fooBlock ^[ :foo | foo bar ]
otherMethod object setBlock: self fooBlock
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*.
dave
-- j. david farber oo architect+mentor numenor labs incorporated in sunny boulder colorado dfarber@numenor.com www.numenor.com
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@earlham.edu || || drawer #419 Earlham College | (765) 973-2537 || || Richmond, IN 47374 | || -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
squeak-dev@lists.squeakfoundation.org