On Sun, 3 Jun 2001, Guy N. Hurst wrote:

>
> Chris Moline wrote:
> > ...
> > a) we could change array[i] to use the hash style. ie array{i}
> >
> > b) we could swipe -> from c. so array->i and maybe hash->"key" too.
> >
> > What think?? They are just suggestions
> >
>
> Yikes! I hate "->"  much more than "<...>"
> And array{i} won't go over well, either, since it has
> such a different meaning already.
>
Yikes is right. :) I still have nightmares about perl's array
and hash reference operators.

Anyway, seems to me there is only one problem with leaving
the || operator alone, and that is a user can trip themselves
up by destroying the value of a variable. Also, the altering
of an external variable but not the creation of that variable
seems kind of confusing.
E.G.

  a = 2
  5.times {|a| puts a}  # => a is has changed
  puts a # => 4

  or if a is not defined outside

  5.times {|a| puts a}  # => 0 1 2 3 4
  puts a # => NameError: undefined local variable or method `a'


I was first surprised by this when I began using Ruby but
quickly worked around it by making sure I use unique variable
names for my loops. However, this is a potential source of
bugs in a program.

I would prefer to have the current meaning of ||
altered to be local to the block only. My reasons
for this are that:
  1) I think there are few programs that rely on this quirk
  2) It is not good programming practice to rely on this quirk.
     If you did this you deserve to have your code broken :)
  3) If you need the old effect (ie, export a variable), it
     is easy to explicitly implement (although a bit ugly):

     a_
     5.times {|a| puts a; a_ = a}
     a = a_

BTW, I have read several posts asking to see code where
someone needed to see a value exported. I am still unclear
on this point. I suppose if you exited early from a block
that that would create a real need for exporting a value.
BTW, how do you exit early from a block?




=========================================================
Jim Freeze
jim / freeze.org
---------------------------------------------------------
No comment at this time.
http://www.freeze.org
=========================================================