On 5/28/07, Tomas Pospisek's Mailing Lists <tpo2 / sourcepole.ch> wrote:
> On Mon, 28 May 2007, Michael Hollins wrote:
>
> > arcadiorubiogarcia / gmail.com wrote:
> >> On May 27, 12:31 pm, Michael Hollins <m... / hollins.id.au> wrote:
> >>> arcadiorubiogar... / gmail.com wrote:
> >>>
> >>>> 1. Are there any plans to introduce function currying? It's a very
> >>>> useful feature for function expressions, and it won't be very
> >>>> difficult to add. In fact, far I've seen a few implementations of it
> >>>> out there. They seem to be more or less ok, but it would be great to
> >>>> have it on the standard distribution.
> >>> what would you want beyond the following?
> >>>
> >>> http://moonbase.rydia.net/mental/blog/programming/currying-in-ruby
> >>
> >> Well I would want something more implicit, like in Groovy for
> >> instance:
> >> http://www.ibm.com/developerworks/java/library/j-pg08235/index.html
> >>
> >>
> >
> > So, just so I understand, take the following example:
> >
> >  def multiply(a,b)
> >    a * b
> >  end
> >
> >  triple = lambda { |a| multiply(a,3) }
> >
> >  puts triple.call(10)
> >
> > I believe you are saying that you'd like the last line to be:
> >
> >  puts triple(10)
> >
> > Is that right? If so, then I agree that would be nice. I'm guessing that it's
> > difficult to achieve in ruby due to the fact that functions can be called
> > without the parentheses. So, for example if I defined the following
> > uninteresting lambda:
> >
> >  six = lambda { multiply(2,3) }
> >
> > then the following would be ambiguous:
> >
> >  puts six
> >
> > Am I trying to invoke the lambda, or am I trying to print the value of the
> > object? To resolve the ambiguity I cannot invoke a lambda with the above
> > syntax. Instead I need to do:
> >
> >  puts six.call()
> >
> > I'd like to hear from the experts if that is the reason or whether there is
> > something more fundamental. I'm still learning ruby (and liking it BTW), so
> > others will likely have a clearer perspective.
>
> The ambiguity is there allready
>
> If I write:
>
>     puts nuts
>
> Then nuts can either be a variable that will return its value, or it can
> be a function call that will return the result of calling it. In that
> sense being able to call (from your example above):
>
>    puts six
>
> would be IMHO perfectly sensible, since it would be neither more nor less
> ambiguous then ruby's default behaveour.
> *t
>
> --
> -----------------------------------------------------------
>    Tomas Pospisek
>    http://sourcepole.com -  Linux & Open Source Solutions
> -----------------------------------------------------------
>
>

Yes, but a method is not an object, whereas a Proc is.  So we don't
know if we want to inspect or call the Proc, it can be reasonably
assumed you want to call the method because, there is no way to
inspect the method without trapping it.

-- 
Chris Carter
concentrationstudios.com
brynmawrcs.com