[squeak-dev] A question about block closures.
dave at nexttolast.com
Tue Jul 7 22:58:36 UTC 2009
I have a question for some of Squeak gurus on the list. I've been porting a
of porting it, added an ad hoc object class that handled the prototype based
One of the issues I encountered was that when I did a copy of my object, the
block closures supplied for various properties required a bit of a hack so I
have a method:
"Generic catch all that performs all selectors"
(self can: aMessage selector) ifTrue: [
(self s: aMessage selector ) outerContext receiver: self.
^( self s: aMessage selector )valueWithEnoughArguments: aMessage arguments
^ self s: aMessage selector.
Now this seems to do exactly what I wanted 99% of the time. It mimics the
all other objects are returned as intended. The #s: method returns nil if
the property is not found in the object's dictionary as well, and #can: is
just a fancy way to test if the property is a block
closure. By using valueWithEnoughArguments: it even gets padded out
with nils like JS would.
I'm not entirely happy with how hackish this seems, patching the
outerContext and then re-rolling the arguments array to one of the
proper size just to copy into a MethodContext.
My question is "Is there a better way?"
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev