Joey Gibson
11/17/2003 4:11:00 PM
Gavin Sinclair wrote:
>On Monday, November 17, 2003, 6:22:18 PM, gabriele wrote:
>
>
> someone would please explain this to me ?
>
>
>
>The slide demonstrates it adequately. Given the above code:
>
> Foo.new.foo
> # Output:
> # wrap pre
> # pre
> # foo
> # post
> # wrap post
>
>
This is a feature from CLOS that allows you to add hooks to arbitrary
methods. The names 'pre', 'post' and 'wrap' are predefined and can't be
changed. This isn't a generic way to sort of chain methods together;
it's sort of AOP-lite. For any method 'foo' you can define any
combination of foo:pre, foo:post and foo:wrap. According to Matz, you
can't change the parameters in a pre, can't change the return value in a
post, but you CAN do both in a wrap. The output snippet above shows the
order of calls if you define all three.
Joey