Hi,

I wonder if it would be possible if we could define a syntax for multiple
targets on a wrapping method.  
class A
	def meth1
		puts "do stuff1"
	end
	
	def meth2
		puts "do stuff2"
	end

	def:pre meth1,meth2
		log(args)
	end
end

Hmm after writing the example it seems like the

def:pre
def:post

style would show the symantics of this idea through the syntax much nicer
then meth1,meth2 :pre or meth1:pre,meth2:pre.

Of course that last syntax exposes interesting concepts about parallel
method assignment to the same block.  I suppose at the moment that is taken
care of with alias, but if you have special syntax on def forms then
alias can't apply to all methods anymore.

In addition it would probably lots of things, but it just seems that
You could potentially be adding the same pre, post, or wrap method 
to most of the classes methods and some method to chain the definition
would be nice.

Clearly it would have potential issues with method arity and such,
But it seemed an intriguing concept.

As a related note, what would happen if you unbound a pre,post,wrap method.
Or the method they hook onto.  It seems some clarification on differences
between methods/procs will be in order because these AOP methods aren't
really either.  Are they first class objects as well?  Are they full blown
methods?  Can you explicitly name a hook and hook it?

I also was thinking that whichever syntax is worked out for this, assuming
some : syntax exists for extensions to def it would also be nice to be able
to overload this, allowing some interesting potential for programmer defined
syntactic forms.

Just some thoughts I had on these ideas that have been bouncing around in my
head.

Charles Comstock

> -----Original Message-----
> From: Yukihiro Matsumoto [mailto:matz / ruby-lang.org]
> Sent: Thursday, November 27, 2003 10:42 PM
> To: ruby-talk ML
> Subject: Re: pre/post question/idea
> 
> Hi,
> 
> I prefer :pre, :post.
> 
> In message "Re: pre/post question/idea"
>     on 03/11/28, "David A. Black" <dblack / wobblini.net> writes:
> 
> |> Nothing against this idea, just noting how my brain reads Ruby code
> right
> |> now. The x:*** syntax screams special case to me, and this doesn't.
> |
> |My concern is that, as people get used to doing this, x:*** will cease
> |to be a special case, but will still look like one :-)
> 
> That's the point.  Hooking method is a part of metaprogramming, which
> should be handled with care, even in the future.  x:*** are a good
> signs for it.
> 
> 							matz.