From: gwtmp01@... Date: 2005-10-27T06:42:13+09:00 Subject: Re: Meta methods to govern meta data? On Oct 26, 2005, at 3:32 PM, Adam Sanderson wrote: > I think you could extend Object to define something working like this: > comment "Doubles the number" > params :n => "Number to be doubled" > def double(n) > n * 2 > end > It seems to me that if you want to associate annotations with a particular method they need to be syntactically connected to the def/end block. In your example there is no way to do that unless you are proposing that comment and params etc. all become keywords. I'd like to avoid that type of keyword explosion. Thinking out loud... The syntax of a method definition already has a structure that admits to additional "clauses": def name(arg1, arg2) # body rescue # code ensure # code end Why not extend this to something like: def name(arg1, arg2) notes comment "This is a comment" body # body rescue # code ensure # code end Alternatively you could put the notes at the end to avoid the addition of the 'body' keyword. def name(arg1, arg2) # do something notes comment "This is an example" end Another variation would be to have the annotation keyword be an alternate syntax for the start of a method definition: notes description "This method takes two arguments" status :experimental def name(arg1,arg2) # code ensure # code end There is the question of the syntax of the text between 'notes' and 'def'. Probably best to reuse the existing method syntax but treat the "methods" that appear between 'notes' and 'def' as no-ops. A similar syntax could be used to annotate classes: notes description "This is an annotated class" author "Gary Wright" class Sample notes "This is an annotated method" def foo end end For what it is worth, this is very similar to Eiffel's "indexing" clause. Gary Wright Gary Wright