Fritz Heinrichmeyer wrote:
> 
> This p animal -> onion thing is a complete show stopper in using ruby.
> 

Not for me, it isn't...  It is part of the ruby way of doing things
because ruby has balanced closures with iterators, and has allowed
for greater gain in harmony elswhere... 

It is part of the reason why ruby is what it is -- it is also part 
of the price, because it doesn't follow with the conventional way, 
forcing this to be an issue which must be learned.  

I am not saying it isn't an issue, but rather, I don't consider it 
a show-stopper.  

> It is boring that i have to type "my" all the time in perl, but at least i
> am able to.
>

maybe it wasn't pointed out, but in ruby, variables are
already local by default.

The show-stopper you mention is in a different context, because it is
a case where locals are interfering in Ruby.

In practice, it need not be a big issue. First, code is not usually 
so long as to be unmanageable.

Furthermore, others have already provided means (written in ruby)
to let you 'at least [be] able to' do something similar to using 'my'
in case you really think you need it.


Nonetheless, matz has acknowledged there is a problem with how
block-level scope is handled - but it is not the problem you see:

[ruby-talk:12599]
>>>>>>
|1. If you were designing Ruby over again, what would do with the
|   scoping of variables in blocks?

I wouldn't enable block local variable, at least by default.  It's for
making closure/proc object usable (imagine closure without local
variables), but I now think I should have made it optional.
<<<<<<


IOW, it is the automatic enabling of block-locals that is the bigger
cause of surprise, so having some way to optionally do that is the
change being sought. 

I believe 'my' in Perl addresses something similar with respect to 
globals - ruby would only need something like that inside a block
to optionally create block-local vars, and only because of the
closure/proc object.

So, even after the 'real' problem is solved, you'll still be able
turn your animal into an onion if you wish, and you probably still
won't like what you see.

Block parameters in ruby are *not* the same as function parameters.



Guy N. Hurst




-- 
HurstLinks Web Development    http://www.hurstlinks.com/
Norfolk, VA  23510            (757)623-9688 FAX 623-0433
PHP/MySQL - Ruby/Perl - HTML/Javascript