[squeak-dev] Clamato
Robert Krahn
robert.krahn at googlemail.com
Sun Sep 6 12:30:08 UTC 2009
Seems that the semantics of globalEval are also a bit confusing. The
code passed to it is evaluated but the value of the last expression
isn't returned.
#asJavascript returns the method/function as a String but I forgot
that self is bound to this which will be window in the function.
The code below works for me in Safari, but yes it's really creepy :-)
- perform: selector with: anObject
| method evalString |
@class withAncestors do: [:ea |
(ea methodAt: selector) ifNotNilDo: [:m | method := m]].
method ifNil: [self error: 'Method ' , selector , ' not found!'].
performSelf := self.
evalString := 'performResult = (' , method asJavascript ,
').call(performSelf,' , anObject , ')'.
evalString globalEval.
performResult.
Robert
On Sep 6, 2009, at 9:48 AM, Avi Bryant wrote:
> On Sat, Sep 5, 2009 at 10:57 AM, Robert
> Krahn<robert.krahn at googlemail.com> wrote:
>
>> I expected this to work, however, String>>eval just returns the
>> String. The
>> same happens when I try to do '1+1'._eval() in a JS console. Do you
>> know
>> where the problem is?
>
> Javascript's eval has confusing semantics - try using globalEval
> instead. Though, even with that I'm not sure your code would work -
> what do you expect "method asJavascript" to return? I don't think it
> will be anything useful.
>
> Avi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090906/29b5adf3/attachment.htm
More information about the Squeak-dev
mailing list
|