From: Trans Date: 2006-07-23T23:40:10+09:00 Subject: Re: Meta-Meta-Programming, revisited Erik Veenstra wrote: > > I'm not sure the Array abuse is needed if you limit the > > arguement to the array itself, eg. don;t splat it whencalling > > the block > > True. I did that before. But receiving |*args| in blocks is so > common (for me), that I was typing it again and again, > introducing bug after bug. That's why I introduced this > Array-parameter-thing. I see. But |*args| does work just so long as you don't want to _change the args_, doesn't it? > > I'll have to look at the Object abuse again and get back to > > you. > > Please. Okay. Looking at your "Object" example: require "ostruct" class Foo < Struct.new(:aa, :bbb) post_condition(:initialize, Object) do line = caller.select{|s| s.include?(__FILE__)}.shift.scan(/\d+/)[-1] puts "An object of class #{self.class} has been created." puts "The arguments are: @aa=#{aa} and @bbb=#{bbb}." puts "The object has id: #{__id__}." puts "It's done on line: #{line}." puts end end So you're confining the context of excution, shutting out the defining closure. Correct? It seems reasonable, though couldn't one do that on their own if they wanted? Eg. class Foo < Struct.new(:aa, :bbb) post_condition(:initialize) do instance_eval do line = caller.select{|s| s.include?(__FILE__)}.shift.scan(/\d+/)[-1] puts "An object of class #{self.class} has been created." puts "The arguments are: @aa=#{aa} and @bbb=#{bbb}." puts "The object has id: #{__id__}." puts "It's done on line: #{line}." puts end end end These parameter "abuses" certainly make particular uses more succinct, but on the downside, they are more syntax to learn, as opposed to being able to draw upon what one already knows about Ruby. T.