"Hal E. Fulton" <hal9000 / hypermetrics.com> writes: > define_hook(:length) do > puts "I'm calculating the length" > prior > end [ ...etc... ] I'd rather see something like this: def foometh(arg) puts "I got #{arg}" end foometh.before = proc { |arg| puts "This is before, with #{arg}" } foometh.around = proc { |arg, this| puts "This is before, with #{arg}" this.call(arg) puts "This is after, with #{arg}" end foometh.after = proc { |arg| puts "This is after, with #{arg}" } That way advice is just an attribute of a method that can be introspected like anything else, instead of invisible, magical attributes of a method. This is especially important with advice, because advised methods/functions can cause a program to behave in ways the casual reader wouldn't expect. Not being able to query a method about its advice from e.g. irb would make problems with advised methods *really* hard to debug. The "before", "around", etc. accessors to foometh should probably be arrays, so that there can be multiple pieces of advice. Of course, the above is utterly invalid Ruby, because functions are not first-class objects, and is thus even more of a fantasy than your example ;). But a guy can dream. It would also be nice if Ruby's methods implicitly defined 'this' to point to the current method; otherwise as in the above example it has to be added as an additional argument to the "around" advice. Dan -- /^Dan Debertin$/ | airboss / nodewarrior.org | www.nodewarrior.org |