adding methods to instances

Ned Konz ned at bike-nomad.com
Wed Apr 11 21:13:00 UTC 2001


> --- drozenfa at iname.com wrote:

> > 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]

If I understand this correctly, you're using aCollaborator's compiled method 
in your own class.

What happens when aCollaborator's compiled method refers to one of its 
instance variables (which could be different than yours)? AFAIK, inst var 
references are by slot number.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list