[squeak-dev] Clamato

Avi Bryant avi at dabbledb.com
Sun Sep 6 07:35:02 UTC 2009


On Sat, Sep 5, 2009 at 8:12 PM, Jason Rogers<jacaetevha at gmail.com> wrote:
> Have you tried that? It doesn't seem to work for me. Tried saving it
> on Object, but it's not invoked as far as I can tell.

So, I think the problem you're running into is nothing to do with the
implementation of #perform:with:, but rather with the hackish way in
which Javascript-native types like Number and String "inherit" from
clamato.Object, which is to say that they don't - the Object methods
just get copied into them on load (this avoids adding any properties
to the real Javascript root Object, which is important for
compatibility with other JS code).

If, after adding perform:with: to Object, you run clamato._setup() in
the JS console, your refactoring should start working.

Avi

>
> I am trying a different refactoring, like so:
>
> - renderOn: html
>        ...
>        self renderButtonFor: '+' on: html.
>        self renderButtonFor: '-' on: html.
>        ...
>
> - renderButtonFor: operation on: html
>        html button
>                with: operation;
>                onClick: [@counter := @counter perform: operation with: 1. self reload].
>
> On Sat, Sep 5, 2009 at 12:43 PM, Avi Bryant<avi at dabbledb.com> wrote:
>> On Sat, Sep 5, 2009 at 8:07 AM, Jason Rogers<jacaetevha at gmail.com> wrote:
>>> A (hopefully) simple question. How would you implement #perform:with:
>>> ? JS can handle the reflection (either via eval(...) or function
>>> pointers).
>>
>> Here's an implementation as a primitive:
>>
>> - perform: aString with: anObject {
>>     return this[aString._mangleSelector()](anObject);
>> }.
>>
>>
>
>
>
> --
> Jason Rogers
>
> "I am crucified with Christ: nevertheless I live;
> yet not I, but Christ liveth in me: and the life
> which I now live in the flesh I live by the faith of
> the Son of God, who loved me, and gave
> himself for me."
>    Galatians 2:20
>
>



More information about the Squeak-dev mailing list