From: Robert Klemme Date: 2008-05-20T23:55:19+09:00 Subject: Re: Method as first class member 2008/5/20 Guoliang Cao : > Robert Klemme wrote: >> With these questions I always ask myself what do we gain by such a >> change? All changes have some effort attached, some more and some less. >> But it's not worthwhile if the effort outweighs the benefits. What do >> you think are the benefits of this change? Why should we do it? > > I believe we get shorter, more intuitive code with this kind of syntax, > and partial invocation can help DRY in a lot of cases. Compare below > examples, what do you prefer? IMHO, the former syntax attracts > programmers to use, the latter is like, do this if you have to(this may > not be a bad thing though) > > "foo"->length > "foo".method :length How often is this used? I rarely see this so I would say, don' t bother. Also, sometimes it can be helpful to be more verbose to clarify that something special is happening there. Also, having a rusty C and C++ background I would expect the first syntax to actually execute the method and not return a meta data object. Partial specialization might be a different story but I did not have use for that either. IMHO making Ruby a functional language does not work too well. And actually you *can* have partial specialization with lambdas. > I do agree changes require efforts and also add learning burden to > users, language designers/implementers have to be very careful with any > change to the language. However, most programmers have a dream - a > perfect language. Even it may not become true, we are closer than ever. > Do you agree? No. I for my part do not dream of a perfect language because I do not believe something like that is possible. Also, I do not believe that your proposed change would be an improvement worthwhile considering. I prefer to use Ruby the way it is vs. worrying too much about improvements. Kind regards robert -- use.inject do |as, often| as.you_can - without end