From: Ryan Pavlik Date: 2003-11-23T17:02:13+09:00 Subject: Re: Method wrapper question (was "stereotyping (was ...)) On Sat, 22 Nov 2003 23:33:57 +0900 "Christoph" wrote: > ts wrote: > ... > > Yes, and this is why I prefer this scheme to > > > > class A > > def a:pre > > end > > > > def a:pre > > end > > > > def a > > end > > end > > Agreed 100% - I see no reason for allowing several hooks in the same class. > > /Christoph > Hmm, actually, there are a lot of good reasons for allowing multiple hooks in the same class. This is, AFAIK, the point of having hooks at all... so many people can hook into them. For instance, you may add a method:pre hook to check some parameter values, make sure they're in range. You may include a package which adds a :pre hook to add permissions. Etc. If you can only have one hook, what's the difference between doing this: class Foo def bar:pre # pre stuff end def bar # body stuff end end and doing this: class Foo def bar # pre stuff # body stuff end end or even this: class Foo def bar_pre # pre stuff end def bar bar_pre # body stuff end end To answer the question of order, it can either be configurable (I think CLOS allows this) or simply "stack order" (latest defined :pre goes first, latest defined :post goes last, etc.). -- Ryan Pavlik "I wish I had arachna-powers. I would dispense death from the skies." - 8BT