(no subject)

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

(no subject)

Amber Milan Eskridge
Hello

is there something like #canPerfom: or #respondsTo: in Amber? I'd like to forward some messages to a delegate, that may not understand some messages.

Thanks for any help.
Reply | Threaded
Open this post in threaded view
|

Re:

Bernat Romagosa
Not sure a method like that exists, but you could always do something like:

(MyClass methodAt: #methodName) notNil

Although it smells like you should not be doing that... If you want to forward messages to a delegate, I think you'd better handle that in #doesNotUnderstand:

Cheers,

2011/11/10 Amber Milan Eskridge <[hidden email]>
Hello

is there something like #canPerfom: or #respondsTo: in Amber? I'd like to forward some messages to a delegate, that may not understand some messages.

Thanks for any help.



--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re:

Amber Milan Eskridge
Good Idea, thank you.


So you would suggest something like:

[delegate update: self] on: MessageNotUnderstood do: [].

?


On Thu, Nov 10, 2011 at 6:11 PM, Bernat Romagosa <[hidden email]> wrote:
Not sure a method like that exists, but you could always do something like:

(MyClass methodAt: #methodName) notNil

Although it smells like you should not be doing that... If you want to forward messages to a delegate, I think you'd better handle that in #doesNotUnderstand:

Cheers,


2011/11/10 Amber Milan Eskridge <[hidden email]>
Hello

is there something like #canPerfom: or #respondsTo: in Amber? I'd like to forward some messages to a delegate, that may not understand some messages.

Thanks for any help.



--
Bernat Romagosa.

Reply | Threaded
Open this post in threaded view
|

Re:

Nicolas Petton
I would override #dnu:

#doesNotUnderstand: aMessage
        ^self delegate
                perform: aMessage selector
                withArguments: aMessage arguments

Cheers,
Nico

On Fri, 2011-11-11 at 16:55 +0100, Amber Milan Eskridge wrote:

> Good Idea, thank you.
>
>
>
>
> So you would suggest something like:
>
>
> [delegate update: self] on: MessageNotUnderstood do: [].
>
>
> ?
>
>
> On Thu, Nov 10, 2011 at 6:11 PM, Bernat Romagosa
> <[hidden email]> wrote:
>         Not sure a method like that exists, but you could always do
>         something like:
>        
>        
>         (MyClass methodAt: #methodName) notNil
>        
>        
>         Although it smells like you should not be doing that... If you
>         want to forward messages to a delegate, I think you'd better
>         handle that in #doesNotUnderstand:
>        
>        
>         Cheers,
>        
>        
>         2011/11/10 Amber Milan Eskridge
>         <[hidden email]>
>                 Hello
>                
>                
>                 is there something like #canPerfom: or #respondsTo: in
>                 Amber? I'd like to forward some messages to a
>                 delegate, that may not understand some messages.
>                
>                
>                 Thanks for any help.
>        
>        
>        
>        
>         --
>         Bernat Romagosa.
>        
>
>


Reply | Threaded
Open this post in threaded view
|

Re:

Amber Milan Eskridge
That's inverse to what I'd like to achieve.
The delegate may not implement the methods, therefore this wouldn't help in this case.

What about this?

Object>>#ifPossibleDo
        ^ Proxy new on: self.

Proxy>>#on: anObject
        subject := anObject.

Proxy>>#doesNotUnderstand: aMessage
        ^ (subject methodAt: #methodName) 
                ifNil: [^ subject] 
                ifNotNil: [subject perform: aMessage selector withArguments: aMessage arguments ]
...

self controller ifPossibleDo subviewMoved: aPoint.        



On Sat, Nov 12, 2011 at 12:37 PM, Nicolas Petton <[hidden email]> wrote:
I would override #dnu:

#doesNotUnderstand: aMessage
       ^self delegate
               perform: aMessage selector
               withArguments: aMessage arguments

Cheers,
Nico

On Fri, 2011-11-11 at 16:55 +0100, Amber Milan Eskridge wrote:
> Good Idea, thank you.
>
>
>
>
> So you would suggest something like:
>
>
> [delegate update: self] on: MessageNotUnderstood do: [].
>
>
> ?
>
>
> On Thu, Nov 10, 2011 at 6:11 PM, Bernat Romagosa
> <[hidden email]> wrote:
>         Not sure a method like that exists, but you could always do
>         something like:
>
>
>         (MyClass methodAt: #methodName) notNil
>
>
>         Although it smells like you should not be doing that... If you
>         want to forward messages to a delegate, I think you'd better
>         handle that in #doesNotUnderstand:
>
>
>         Cheers,
>
>
>         2011/11/10 Amber Milan Eskridge
>         <[hidden email]>
>                 Hello
>
>
>                 is there something like #canPerfom: or #respondsTo: in
>                 Amber? I'd like to forward some messages to a
>                 delegate, that may not understand some messages.
>
>
>                 Thanks for any help.
>
>
>
>
>         --
>         Bernat Romagosa.
>
>
>