From: Paul Brannan Date: 2005-10-20T05:12:45+09:00 Subject: Re: Method annotation and anonymous functions On Thu, Oct 20, 2005 at 04:41:51AM +0900, stevetuckner wrote: > What I don't like about that proposal is that these annotations only > take one argument (the symbol) and aren't applied to a Method object > (where the annotations rightly should reside). Changing def to return a Method object could also be done, but this is a larger change; it requires methods like private() to be able to take a Method or a Symbol (currently they only take a Symbol). The annotation does not belong with the (Unbound)Method object; it belongs with the method. This is an important distinction: irb(main):001:0> class Foo; def foo; end; end => nil irb(main):005:0> m1 = Foo.instance_method(:foo); m1.object_id => 538483812 irb(main):006:0> m2 = Foo.instance_method(:foo); m2.object_id => 538477272 Note that m1 and m2 are two *different* objects which refer to the same method. > >Chaining the annotations on multiple lines can be done using '\': > > > > private \ > > module_function \ > > doc("This is a docstring") \ > > def baz(a, b, c) > > # ... > > end > > > > > Aside from looking icky, how does doc() know what symbol to use to apply > the annotation with? Good point, I missed this the first time through. Paul