At 21:27 28/06/2004 +0900, you wrote:
>il Mon, 28 Jun 2004 13:37:21 +0200, "Robert Klemme" <bob.news / gmx.net>
>ha scritto::
>
>>> I was going to ask if we could have this:
>>> callable arg1,arg2 # implicitly looks for #call
>>> callable           # the callable object
>>> callable()         # forces application with zero arguments
>>> ...
>>>
>>> what's wrong with this?
>>
>>Ambiguity.  "callable arg1,arg2" denotes an invocation of the method
>>"callable" of "self".  "callable()" also invokes the same method albeit
>>without arguments.
>
>well, but ambiguity exists anyway, just think of :
>
> print p
>
>"p" may stand for self#p, or a local variable named "p". 
>
>More, using a method passed in via argument won't be different from
>defining a new one in the current scope explicitly (actually, a method
>def in  a method ends up in the self scope), I mean: it's up to the
>user to be smart enough, writing something like:
>
>def comb(fun1,fun2) 
>
>instead of 
>def comb(print,puts)
>
>>However, you can use #[] like this:
>
>yes, I know, but using #[] is somewhat even worst than #call.
>
>It is better because it looks like () yet it's worst because it just
>mimics something hiding it's meaning, whereas #call at least is
>explicit.

It may look more understandable if you think of [] as of
a "dereference" operator. In my rcr.rb I added a:
class Proc
  def []=( *args )
    self[*args]
  end
end
... so that a Proc can act as a lvalue, much like a
method can.
xxx[]  reads as "content of xxx"
xxx[] = yyy  reads as "set content of xxx to yyy"

This is the closer to a "transparent" dereferencing
scheme I managed to get so far.

Yours,

JeanHuguesRobert



-------------------------------------------------------------------------
Web:  http://hdl.handle.net/1030.37/1.1
Phone: +33 (0) 4 92 27 74 17