Hello --

On Fri, 26 Apr 2002, Jean-Hugues ROBERT wrote:

> At 22:59 25/04/2002 +0900, Lars Christensen wrote:
> >   [7,3,1,7,8,2,3,2].sort { |a,b| a <=> b }.map { |a| a**2 }
> >This is more readable IMO:
> >   [7,3,1,7,8,2,3,2].sort { a <=> b }.map { a**2 }
> >I like this implicit stuff at work here, but I would perhaps create too
> >much conflict with other variables? How about allowing the |n| to be put
> >anywhere in the block?:
> >   [7,3,1,7,8,2,3,2].sort { |a| <=> |b| }.map { |a|**2 }
> >--
> >Lars Christensen, larsch / cs.auc.dk
>
> Very nice indeed. When is binding resolved, compile or run time ?
> p = proc { if |a| then |c| else |b| end }
> Ex:
>    A) p.call( 1, 2, 3)   => 2
>    B) p.call( nil, 2, 3) => 2 or 3 ?
> I would prefer 3. This implies that binding of params to variables is done
> at compile time. On the contrary, if |x| semantic is to "consume" the
> "next" parameter (at runtime) then b would be assigned 2 and that is weird.

Have you chosen a name for this new language? :-)

But seriously....

I'd refer you to the passage headed "Compile Time? Runtime? Any Time!"
in the pickaxe book:

  The important thing to remember about Ruby is that there isn't a big
  difference between ``compile time'' and ``runtime.'' It's all the
  same. You can add code to a running process. You can redefine
  methods on the fly, change their scope from public to private, and
  so on. You can even alter basic types, such as Class and Object.


Consider this (which I know can be attacked as an example because it
uses the ever-controversial eval, among other things, but anyway):

  pr = proc { |a,b,c| if a then eval c else puts b.succ end }
  pr.call(rand(2)>0,"hi","puts b")

The door is open for anyone wanting to give a non-horrible example :-)
But generally I think the { if |a| ... } notion doesn't hold up very
well in the face of the "Any Time!" principle.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav