From: "David A. Black" Date: 2009-01-14T23:12:55+09:00 Subject: Re: functional programming Hi -- On Wed, 14 Jan 2009, Pascal J. Bourguignon wrote: > "David A. Black" writes: > >> Hi -- >> >> On Wed, 14 Jan 2009, Pascal J. Bourguignon wrote: >> >>> Mike Gold writes: >>> >>>> Pascal J. Bourguignon wrote: >>>>> Mike Gold writes: >>>>> >>>>>> Why is func.call() or func[] or func.() "very useful" compared to >>>>>> func()? As I mentioned, in every case I've found it to be a >>>>>> hassle, for the reasons previously stated. >>>>> >>>>> The reason is because Ruby is a lisp-2. The same name can be used to >>>>> designate both a method and a variable. So you need two syntaxes, to >>>>> make reference to the method of a name, or to the variable. >>>> >>>> No, that's not the reason. It is because Ruby allows method invocation >>>> without parens. Therefore parens cannot be used to unambiguously >>>> "dereference" a function. >>> >>> It wouldn't matter if we had not to distinguish calling a named >>> function from calling a function stored in a variable. >> >> But what would this be: >> >> f = lambda {} >> def f; end >> f() > > It's clear, f() calls the def f. > You need and have another expression to call the lambda. > > And this is because there are two things that are designated by the identifier f here: Right -- that's my point :-) I thought that you were suggesting the unification of calling a method and calling a function that's stored in a variable. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!