From: mathew
Date: 2005-08-12T01:36:14+09:00
Subject: Nested methods and define_method (was Re: Yet Another useless Ruby 2 Idea)
gabriele renzi wrote:
> it is, I wrote that method nesting should be prohibited, thus your
> second interpretation is invalid and thus there is no ambiguity.
Well, I disagree with prohibiting nested methods.
> Nested method definitions are mostly useless anyway because of the
> method scoping (actually, I think I never saw an example of using a
> nested def instead of a define_method in some years of rubying :)
What do you mean? When I try it, a nested method is scoped so that it
is only visible inside the method it's defined in. That's exactly the
behavior you want for nested methods to be useful.
Seems to me that define_method is for creating and redefining methods
dynamically, which is an orthogonal problem. Then again, I've never used
it or seen it used, so I may be misunderstanding what it's for.
"Programming Ruby" doesn't seem to have any detail on what it's for or
why you'd want to use it.
mathew
--
WE HAVE TACOS