mental / rydia.net wrote:
> Quoting Trans <transfire / gmail.com>:
>
> > You are right in that there is a caveat for having this in that
> > you need to know that they are going to be "anonymous methods"
> > in order to pass them around. But the same is true for calling a
> > proc, i.e. you have to know it's a proc to call it.
>
> Actually, no, you just need to know it's a Callable.  Or duck-typed
> like one.  Could be a continuation, or a proc, or some proxy object
> I just invented.
>
> I find that to be a very, very valuable property.
>
> > def proxy(a)
> >   if lambda? a
> >     actual(->a)
> >   else
> >     actual(a)
> >   end
> > end
>
> Try:
>
>  def proxy(a)
>    if respond_to? :call
>      actual(->a)
>    else
>      actual(a)
>    end
>  end
>
> If we do this, -> ought to work on anything that understands :call.

So instead of depending on the class of object, you're duck-typing the
concept. Thus any object could participate in the bahavior, even change
on the fly. Interesting notion. I would use a different method to
prevent backward incompatability though, say:

  class X
    def initialize(x)
      @x = x
    end
    def implicit_call
      x
    end
  end

  a = X.new(100)

  a     #=> 100

  ->a   #=> #<X...>


Implict lambdas are useful are useful as convenient lazy evaluators. I
wonder how th above might be useful. It's sort of like a proxy, but
more fundamental (?).

Also, It might be difficult to implement efficiently.

T.