Pragma to Distribute Copies of Methods

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

Pragma to Distribute Copies of Methods

Peter Suk

Folks,

 

I’d like to implement a pragma that causes the method wherein the pragma invocation is contained to overwrite all other methods of the same name.  This is to implement a lightweight “Generalization Interface” feature.  I’m not sure there is a clean way to do this.  It seems that pragmas are really meant to annotate methods so that they can be found at a later time.  So the only way I’ve found to execute code when you’re saving a method with a pragma is to add a hook into Behavior>>addSelector:withMethod:.   This won’t work with code stored in BOSS files, but this doesn’t concern me. 

 

So, is there a better way to do this?

 

--Peter

Reply | Threaded
Open this post in threaded view
|

RE: Pragma to Distribute Copies of Methods

Peter Suk

One could override #changeSelector:class:attributes: and #addSelector:class:attributes: in ChangeSet, or otherwise hook into ChangeSet or XMainChangeSet. 

 


From: Peter Suk [mailto:[hidden email]]
Sent: Wednesday, December 19, 2007 12:26 PM
To: VWNC
Subject: Pragma to Distribute Copies of Methods

 

Folks,

 

I’d like to implement a pragma that causes the method wherein the pragma invocation is contained to overwrite all other methods of the same name.  This is to implement a lightweight “Generalization Interface” feature.  I’m not sure there is a clean way to do this.  It seems that pragmas are really meant to annotate methods so that they can be found at a later time.  So the only way I’ve found to execute code when you’re saving a method with a pragma is to add a hook into Behavior>>addSelector:withMethod:.   This won’t work with code stored in BOSS files, but this doesn’t concern me. 

 

So, is there a better way to do this?

 

--Peter

Reply | Threaded
Open this post in threaded view
|

Re: Pragma to Distribute Copies of Methods

Travis Griggs-3
In reply to this post by Peter Suk

On Dec 19, 2007, at 10:25 AM, Peter Suk wrote:

> Folks,
>
> I’d like to implement a pragma that causes the method wherein the  
> pragma invocation is contained to overwrite all other methods of the  
> same name.  This is to implement a lightweight “Generalization  
> Interface” feature.  I’m not sure there is a clean way to do this.  
> It seems that pragmas are really meant to annotate methods so that  
> they can be found at a later time.  So the only way I’ve found to  
> execute code when you’re saving a method with a pragma is to add a  
> hook into Behavior>>addSelector:withMethod:.   This won’t work with  
> code stored in BOSS files, but this doesn’t concern me.
>
> So, is there a better way to do this?
>

Whenever a method with a <method tag> is changed, added, or removed,  
the object for which it happens is sent either classMethodsChanged or  
instanceMethodsChanged.

Yes I agree, they're not "pragmas" in the conventional sense, since  
that term is usually used as a "compiler directive." The only example  
of this is the <primitive: #> tag. Which is why... you rarely see me  
use the term. :)

--
Travis Griggs
Objologist
Time and Countertops. They both get used up way too fast.