From: Bob Hutchison Date: 2005-10-20T21:59:47+09:00 Subject: Re: Method annotation and anonymous functions On Oct 20, 2005, at 7:47 AM, David A. Black wrote: > Hi -- > > On Thu, 20 Oct 2005, Jeff Wood wrote: > > >> It's really a VERY cool idea. I really hope it makes it in. I know >> most people seem to hate adding a little punctuation ... but >> sometimes >> it can be a good thing. What punctuation has to be added? I like the way it is done in the example. >> > > The thing is, I've spent literally years watching literally dozens and > dozens of things being suggested, *all* of which involve new > punctuation and all of which someone thinks are good ideas. If even a > tenth of them were adopted, Ruby would be about 90% of the way to > being in the Perl bracket of punctuation intensity. > > I know it sounds strange, but I actually consider the clean line of > Ruby a "feature" (albeit an optional one, as to its use :-) which > counts for more than almost every RCR imaginable to me. I agree about the syntax. The example that Tran provided doesn't require new syntax, it works, and it does something that I think is *very* useful. I'll reproduce his example here: >> class X >> def foo ; "foo" ; end >> ann :foo, :returns => String >> end >> >> X.ann :foo, :log => true >> >> X.ann.foo.returns #=> String This is simple and so unexpected, to me at least, that it seems brilliant (forget the :returns bit, it is irrelevant). I think I'm still not used to what can be done with the mixing of compilation and runtime in ruby. I tried writing a toy implementation of this last night to see if it'll solve a problem that I'm going to have to deal with soon. I'm working on a system that automatically augments class definitions and this is a great way for a programmer to provide additional hints and fine-tuning control -- in fact, this opens up a lot of possibilities. The implementation I came up with requires that include/extend trick that Robert Klemme mentioned in the "class method aliasing" thread the other day, but still. I'll soon cheat and look at what nitro and facets did. Cheers, Bob > > > David > > -- > David A. Black > dblack@wobblini.net > > ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur --