On Mon, 12 Mar 2001, W. Kent Starr wrote:

> Howabout creating a "strict" local using a prefix in front of an alpha 
> (excepting symbols like $) as in _var to mean LOCAL! LOCAL!! LOCCAL!!!
> as in :
> 
> x = 5; loop { |y| x = 3; x * y }; puts x ->5
> x = 5; loop { |y| _x = 3; _x * y }; puts x -> 3

I think this is the best suggestion I've seen so far, though it needs
to be better defined to cover this scenario:

  x = 5; loop {|y| _x = x + 5; loop {|y| puts _x } }

Does the _x carry over from the parent loop?

In any event, I think the whole concept of block local variables is a
solution in search of a significant problem.

200 line methods scream out more for a refactoring than a language
extension. A beginning programmer is definitely going to get some
things wrong, but providing a language extension to cater for this
isn't going to help a lot. Their code is likely to be broken in more
ways than just local variables.

What if the beginning programmer opened a file inside one block and
reads from it in other blocks in a fixed order? Moving the blocks
around is still going to screw that up regardless of "my local"
statements. What about GUI calls? Global variables?

There's a lot of other problems in programming that are equally annoying.
For example I would like to be able to change a method or variable name
and have it automatically updated throughout the project. Can I have a
language extension for that?

Ruby is clean because it only provides solutions for common problems.

Perl is messy because it provides solutions for minor problems.

The more additions to Ruby, the more stuff I have to know before I
understand Ruby, and the harder other people's programs become to read.

-- 
  spwhite / chariot.net.au