[squeak-dev] A question about block closures.
David Goehrig
dave at nexttolast.com
Wed Jul 8 12:22:56 UTC 2009
Yes actually both of those. Russel's work was part of the inspiration
behind the js code I am porting. But I am not happy with what they did.
Don't get me wrong. What I did works 99% of the time. I'm just afraid
that the next step involves some additional vm hacks.
-=-=- dave at nexttolast.com -=-=-
On Jul 8, 2009, at 8:01 AM, Igor Stasenko <siguctua at gmail.com> wrote:
> David, have you tried to use/evaluate a Prototype package for own
> purposes?
>
> http://wiki.squeak.org/squeak/1369
>
> 2009/7/8 David Goehrig <dave at nexttolast.com>:
>> Dear Squeakers,
>> I have a question for some of Squeak gurus on the list. I've been
>> porting a
>> javascript project I did a couple months back to Squeak, and in the
>> process
>> of porting it, added an ad hoc object class that handled the
>> prototype based
>> inheritance I used in the javascript version.
>> 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:
>> doesNotUnderstand: aMessage
>> "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
>> behavior of using a block closure as a javascript function() {}
>> object, and
>> 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?"
>> Dave
>> --
>> -=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/
>>
>>
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
More information about the Squeak-dev
mailing list
|