il Mon, 17 Nov 2003 22:23:27 +0900, Gavin Sinclair
<gsinclair / soyabean.com.au> ha scritto::

>On Monday, November 17, 2003, 6:22:18 PM, gabriele wrote:
>
>> I just looked at matz' slides and I don't have a clear understanding
>> of ho9w this is suposed to work.

>
>The slide demonstrates it adequately.  Given the above code:
>
>  Foo.new.foo
>  # Output:
>  #   wrap pre
>  #   pre
>  #   foo
>  #   post
>  #   wrap post
>

I'm dumb I can admit thois :)
But, This could work both with idea #2 or #3. 
The point is: if #2 is right (pre is called before the method. post is
called after the real method. wrap can call super.) what is the need
for pre and post? thay can be easily done transparently with wrap?

Does foo:post add itself to the first foo() definition or to the
latest redefinition?

what is the 'method resolution order' for method wrapping?

wrap->post->pre?

pre->post->wrap?

latest-definition-wins ?

if I did:

class Foo
 def foo:wrap (*args) #4
  p 'wrap pre'
  super
  p 'wrap post'
 end
 def foo(*args)       #1
   p 'foo'
 end
 def foo:pre (*args ) #2
  p 'pre'
 end
 def foo:post (*args) #3
  p 'post'
 end
end

Foo.new.foo would give the same output or would it give
 
 pre 
 wrap pre
 foo
 wrap post
 post

?

sorry for being stupid :(