adding methods to instances
Luciano Notarfrancesco
lnotarfrancesco at yahoo.com
Wed Apr 11 21:06:00 UTC 2001
Dan Rozenfarb had troubles trying to send this mail,
and I'm acting as relay.
--- drozenfa at iname.com wrote:
>
>
> Jim Menard wrote:
> > Great ideas. How about using delegation and
> #doesNotUnderstand:
>
> instead?
> >
> > Add an instance variable to object called
> delegate. Override
> > Object>>doesNotUnderstand: to pass the message to
> delegate, if it is
>
> not
> > nil. Perhaps provide a setter method or two. Add a
> new delegate
>
> object to
> > your object and voila! new methods.
>
> But depending on how you resend the message you'll
> be delegating or
>
> just forwarding the message.
> In an ongoing work (my master's thesis, that I will
> hopefully post soon
>
> on BSS) I used this:
>
> delegate: aMessage toObject: aCollaborator
> | method selector |
>
> method := aCollaborator class >> aMessage
> selector.
> selector := ('tempMethod', ($a to: $i) shuffled)
> asSymbol.
> self class addSelector: selector withMethod:
> method.
> ^ [self perform: selector withArguments: aMessage
> arguments ]
> ensure: [self class removeSelectorSimply: selector]
>
> this way you can keep the right delegation semantics
> for messages sent
>
> to self.
> It is based on
> CompiledMethod>>valueWithReceiver:arguments:
>
>
> Joshua Channing Gargus wrote:
> >Someone did prototype in Squeak before; I don't
> remember who.
> > Check the archives; I think it might be what
> you're looking for.
>
> Hans-Martin Mosner did, and my work is related to
> his but
>
> Morphic-Oriented and with some extra features
> (though some of theirs
>
> are still missing)
>
>
> Cheers,
>
> Dan Rozenfarb
>
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
More information about the Squeak-dev
mailing list
|