Arnaud Meuret <ameuret / blocks4you.com> wrote:
>
> > Suddenly your program goes crazy because someone already introduced 
>local
>'i' in
> > one of the enclosing scopes might be 200 lines earlier and it holds some
>other
> > magic number like 12345. Now my innocently looking 'for' loop resets the
>value
> > of 'i' to 10 which is a BUG.
>
>Am I right to be shocked by some points (3) here ?

I doubt it.

>What kind of collaborative programming is that ?

Consider what happens in the real world when person A
is handed code that someone who didn't know how to
program produced.  (This is not an uncommon situation,
and if Ruby becomes popular it will happen in Ruby as
well.)

>1) Two (at least apparently) developpers working on the same "function"
>(enclosing scopes)
>    and unaware of the current set of local variables

This can reasonably happen when one scope encloses the
other through an eval statement.  It can realistically
happen when one developer is assigned a task to make a
change in something produced by another.  Now I grant
you that a good programmer is probably going to put
their change into a new function.  But that still doesn't
solve the eval issue.

>2) A "function" (enclosing scopes) more than 200 lines big !

Beginners will make that mistake because that is what
beginngers do.  Just because I am competent does not
mean that I will always work with code that is written
by other competent people.

>3) An *innocent* 'for' loop with i as iteration variable !!!!!! I didn't
>know such a thing existed !
>    I suppose you might just as well write an innocently looking Hannibal
>Lecter !

What did I say about beginners?

And not always beginners.  I am reminded of some JavaScript
that I couldn't get straight until I named my variables
x and y and put at the top a big comment, "THINK CARTESIAN
COORDINATES".  Say as much as you like about verbose
variable names, and I won't believe you.  Talk to me about
*meaningful* variable names, and I am all over that.  But
in that case a picture was worth a thousant words.

>How can it be decently requested that a language protects you from such a
>density of Bad Things(tm) ?

It is impossible to protect yourself from bad programmers.

But it would be nice to make having to help them as
painless as possible.

>I am aware that local variables in ruby blocks, with possibly nested scope
>bindings and stuff can be tricky to handle for a newcomer BUT the quoted
>argument is a little bit too much.

An incidental note.  My reason for wanting the feature
is that I would like to see something like Perl's strict
built on top of it.  I am willing to do the extra typing
if I get a spellcheck out of it.  (Which is really all
that Perl's strict is.)  Have Ruby keep track of variables
used without explicit declarations, and method names
called in a functional style.  Have a declaration which
can be made that asserts that all variables were declared,
and all functions should now be defined.

Instant tyop check!  Very useful in my experience.

Cheers,
Ben
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com