Leaning Smalltalk - how to modify BlockContexts
cputney at wiresong.ca
Sun Jun 13 23:55:28 UTC 2004
On Jun 13, 2004, at 6:13 PM, Edouard Poor wrote:
> So my questions are:
> 1/ Is BlockContext something I cannot easily change without changing
> the primitives in Squeak?
Yes. Blocks are pretty fundamental to the system, so if you need to
make changes to how they work, you have to hack on the VM.
> 2/ How can I, at least in my simple bindSecond attempt above, make the
> new BlockContexts home the same as the original?
I don't know. I suspect you'd have to hack the compiler to be able to
create BlockContexts from scratch, particularly if you want them to
have home contexts that they're not actually part of.
> 3/ Since no-one has added ways of binding arguments in Smalltalk
> before now, I assume that it's just not a pattern that is used - is
> that correct? Are there other ways of passing simple actions around
> and being able to manipulate them?
Yes, it's correct. For passing simple actions around and manipulating
them, Smalltalkers typically use blocks. What need do you have that
blocks don't fulfill? To curry block parameters, I'd do the following:
multipleBlock := [:a :b | a * b].
doubles := [:a | multipleBlock value: a value: 2].
x := doubles value: 12
(Damn, Brian just beat me to the punch with this example.)
More information about the Squeak-dev