From: stevetuckner Date: 2005-10-20T03:26:49+09:00 Subject: Method annotation and anonymous functions I want to start a discussion about two things that Matz talked about at the rubycon. Dave Thomas suggested that we could get Matz' anonymous function by using "def" without a name. Others suggested that if def returned a method object, then annotations could be applied to that object. So here goes my suggestions. As they stand, they are not even parseable by Ruby, but lets start talking about it anyway. Anonymous functions: x = def (a=1,b=2) { ... } y = def(a,b=3) begin ..... end Annotated functions: class A def foo(a, b) .visibility :private # how can this be parsed? (the above line has no trailing marker to signal it as one expression .returns Integer begin .... end def foo2(a, b).visibility(private).returns(Integer) { ... } f3 = def foo3(a,b) end f3.visibility(:private).returns(Integer) Anonymous, Annotated functions x = def (a, b).visibility(private).returns(Integer) { ... } y = def (a, b) { ... } y.visibility(:private) # apply annotations later y.returns(:integer) where for anonation examples: class Method def visibility(v) @annotations[:visibility] = v return self end def returns(r) @annotations[:returns] = v return self end end Please rake me over the coals because I am so ignorant ;-) Steve Tuckner