From: Joey Gibson Date: 2003-11-18T01:10:49+09:00 Subject: Re: Yet Another Rite Thought: method combination --------------000000030805040502010902 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 --------------000000030805040502010902--