From: transfire@... Date: 2006-07-22T23:40:27+09:00 Subject: Re: Meta-Meta-Programming, revisited Erik Veenstra wrote: > > Sorry, I misprepresnted what I meant. Use "aModule" instead > > of "Module". -- You created a special method: > > #wrap_module_method for doing #wrap_method external to the a > > module/class, but you could just make it public (or use > > send): > > > > aModule.wrap_method > > Wrong!... ;] The receiver of wrap_method is *always* a > module/class. When wrapping an instance method, with > wrap_method, the receiver is a module. When wrapping a module > method, with wrap_module_method, the receiver is the singleton > class of that module. > > So, you should write aModule.meta_class.wrap_method (using > Why's little meta library...). Or, in default Ruby: > > class << aModule > self > end.instance_eval > wrap_method(method_name){...} > end > > I don't want to see this in regular, every day Ruby code. > That's why I came up with this wrap_module_method and this > stupid Module argument thing. ;] Kind of shortcuts... Well, that's the thing. I'd rather do aModule.meta.wrap_method aModule.meta.pre_condition Then have all these different useage forms: wrap_method wrap_module_method pre_condition( aModule, T. > > > * When wrapping methods in both the class and the superclass, > > > going up and down, you can't (at wrap-time) determine the > > > order in which the blocks are to be executed (at run-time). > > > If I run the code below with your wrap_method (after removing > > > the "method does not exist" check), this :wrap_Foo is gone! > > > It's not what _I_ expected... ;] (See [1] for a more > > > complicated example. I'll try to make a diagram.) > > > > Owww! Nice catch. I hadn't though of that. > > ;] On looking at it again, I think it goes back to you wnating to wrap methods that aren;t there. When subclass, there's not much use in wrapping when one can just define the method and call super. > Sure. Everybody is free to copy the code and use it for > whatever reason. If you make money with it, please call me... Money? Don't make it. T.