About little magic to support understanding

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

About little magic to support understanding

Stéphane Ducasse
Hi

I wanted to see what is used in Morph so I did the following

Define a subclass of ProtoObject and redefnied DNU as follow


doesNotUnderstand: aMessage

        | sel category |
        sel := aMessage selector.
        Transcript show: 'Does not understand ',  aMessage selector  
printString ; cr.
        category := (Morph organization categoryOfElement: sel).
        self class compile: (Morph sourceCodeAt: sel) classified: category.
        ^ aMessage sentTo: self.


It works if I copy from Object but not from Morph
does any of you have an idea.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About little magic to support understanding

johnmci
Well for the objective C bridge

MCHttpRepository
        location: 'http://www.squeaksource.com/ObjectiveCBridge2'
        user: ''
        password: ''

I used ProtoObject as the super class of the ObjectiveCObject and  
supplied doesNotUnderstand: to forward messages to the
Objective-C plugin for dispatching Obj-c messages.

In attempting to work with instances of ObjectiveCObject I found I had  
to implement about 20 support methods
so that you could inspect, explore, or recompile. Otherwise tapping  
inspect sends to you la-la land...
Maybe there is a useful clue somewhere in there.


On 27-Feb-09, at 9:31 AM, Stéphane Ducasse wrote:

> Hi
>
> I wanted to see what is used in Morph so I did the following
>
> Define a subclass of ProtoObject and redefnied DNU as follow
>
>
> doesNotUnderstand: aMessage
>
> | sel category |
> sel := aMessage selector.
> Transcript show: 'Does not understand ',  aMessage selector
> printString ; cr.
> category := (Morph organization categoryOfElement: sel).
> self class compile: (Morph sourceCodeAt: sel) classified: category.
> ^ aMessage sentTo: self.
>
>
> It works if I copy from Object but not from Morph
> does any of you have an idea.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================




_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About little magic to support understanding

Stéphane Ducasse
John

normally when a method is not found I copy it from the class to the  
empty copy so slowly it gets automagically filled
up. This is fun you see the result of your actions live.
So normally I should not have the problem you describe. In fact the  
first thing I tried was to inspect the object and it worked
wonderfully .

Now may be Morph is more vicious

On Feb 27, 2009, at 6:44 PM, John M McIntosh wrote:

> Well for the objective C bridge
>
> MCHttpRepository
> location: 'http://www.squeaksource.com/ObjectiveCBridge2'
> user: ''
> password: ''
>
> I used ProtoObject as the super class of the ObjectiveCObject and
> supplied doesNotUnderstand: to forward messages to the
> Objective-C plugin for dispatching Obj-c messages.
>
> In attempting to work with instances of ObjectiveCObject I found I had
> to implement about 20 support methods
> so that you could inspect, explore, or recompile. Otherwise tapping
> inspect sends to you la-la land...
> Maybe there is a useful clue somewhere in there.
>
>
> On 27-Feb-09, at 9:31 AM, Stéphane Ducasse wrote:
>
>> Hi
>>
>> I wanted to see what is used in Morph so I did the following
>>
>> Define a subclass of ProtoObject and redefnied DNU as follow
>>
>>
>> doesNotUnderstand: aMessage
>>
>> | sel category |
>> sel := aMessage selector.
>> Transcript show: 'Does not understand ',  aMessage selector
>> printString ; cr.
>> category := (Morph organization categoryOfElement: sel).
>> self class compile: (Morph sourceCodeAt: sel) classified: category.
>> ^ aMessage sentTo: self.
>>
>>
>> It works if I copy from Object but not from Morph
>> does any of you have an idea.
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> --
> =
> =
> =
> =
> =
> ======================================================================
> John M. McIntosh <[hidden email]>
> Corporate Smalltalk Consulting Ltd.  http://
> www.smalltalkconsulting.com
> =
> =
> =
> =
> =
> ======================================================================
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About little magic to support understanding

johnmci
so what about Morph's abuse of includesSelector: would it be confused  
by asking ProtoObject instance if it
understands #lalaland:



On 27-Feb-09, at 10:02 AM, Stéphane Ducasse wrote:

> John
>
> normally when a method is not found I copy it from the class to the  
> empty copy so slowly it gets automagically filled
> up. This is fun you see the result of your actions live.
> So normally I should not have the problem you describe. In fact the  
> first thing I tried was to inspect the object and it worked
> wonderfully .
>
> Now may be Morph is more vicious
>
> On Feb 27, 2009, at 6:44 PM, John M McIntosh wrote:
>
>> Well for the objective C bridge
>>
>> MCHttpRepository
>> location: 'http://www.squeaksource.com/ObjectiveCBridge2'
>> user: ''
>> password: ''
>>
>> I used ProtoObject as the super class of the ObjectiveCObject and
>> supplied doesNotUnderstand: to forward messages to the
>> Objective-C plugin for dispatching Obj-c messages.
>>
>> In attempting to work with instances of ObjectiveCObject I found I  
>> had
>> to implement about 20 support methods
>> so that you could inspect, explore, or recompile. Otherwise tapping
>> inspect sends to you la-la land...
>> Maybe there is a useful clue somewhere in there.
>>
>>
>> On 27-Feb-09, at 9:31 AM, Stéphane Ducasse wrote:
>>
>>> Hi
>>>
>>> I wanted to see what is used in Morph so I did the following
>>>
>>> Define a subclass of ProtoObject and redefnied DNU as follow
>>>
>>>
>>> doesNotUnderstand: aMessage
>>>
>>> | sel category |
>>> sel := aMessage selector.
>>> Transcript show: 'Does not understand ',  aMessage selector
>>> printString ; cr.
>>> category := (Morph organization categoryOfElement: sel).
>>> self class compile: (Morph sourceCodeAt: sel) classified: category.
>>> ^ aMessage sentTo: self.
>>>
>>>
>>> It works if I copy from Object but not from Morph
>>> does any of you have an idea.
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>> --
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> John M. McIntosh <[hidden email]>
>> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>>
>>
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================




_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About little magic to support understanding

Stéphane Ducasse


> so what about Morph's abuse of includesSelector: would it be  
> confused by asking ProtoObject instance if it
> understands #lalaland:

I have to think :)
Right now it freezes hard :)


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About little magic to support understanding

Igor Stasenko
Hello Stef,

i designed own little thingy to intercept any message sent to an
object, including #DNU.

See, if it can be useful for you.
As an example there is a subclass (CVMsgHandlingProxy) which i'm using
to write an inline code to handle messages right in place where i
creating a proxy:

superReceiver
        "lambda, when reducing , sends #perform:withArguments: ,
        and we doing trick by evaluating perform..inSuperClass"
       
        ^ CVMsgHandlingProxy onMessage: [:msg |
                msg selector == #perform:withArguments: ifTrue: [
                        self receiver
                                perform: msg arguments first
                                withArguments: msg arguments second
                                inSuperclass: self receiver class superclass
                ] ifFalse: [
                         self receiver perform: msg selector withArguments: msg arguments
                ]
        ]

what is cool in this method:

suppose you have a code like following:

proxy := (someObject asSuperReceiver).

and later you sending a messages to it:

proxy foo.

Now, the trick is, that in the end, a message #foo will be sent to
original 'someObject' , but using its superclass (same semantics, as
you using super foo).
What is cool in CVMsgHandlingProxy, that you don't need to declare a
separate class each time you need to have different proxy behavior..
you just write:

makeProxyFor: object
   ^ CVMsgHandlingProxy onMessage: [:msg | msg sentTo: object ]


2009/2/27 Stéphane Ducasse <[hidden email]>:

>
>
>> so what about Morph's abuse of includesSelector: would it be
>> confused by asking ProtoObject instance if it
>> understands #lalaland:
>
> I have to think :)
> Right now it freezes hard :)
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

CVMessageCatchingProxy.st (1K) Download Attachment
CVMsgHandlingProxy.st (914 bytes) Download Attachment