From: Brian Candler Date: 2003-02-02T19:24:32+09:00 Subject: Re: Local variables & blocks On Sun, Feb 02, 2003 at 09:30:12AM +0100, ts wrote: > B> Unfortunately, although I receive ruby-talk in digest form, there are some > B> weeks when I simply have to delete every day's mails. That's just how it > B> goes. I did read [52440], [63087] and [63100] though, and the terminology > B> was ambiguous to me. Does "shadowed" mean "aliased" or "hidden"? > > It's simple : > > * all variables are local except variables found between || which are > block local > > * you have a warning (and shadowing) if a variable found between || was > previously declared Thanks, I just wasn't sure of the definition of "shadowing". As far as I can see it means "a completely different variable, which just happens to have the same name as another one in an outer scope" In C it would be: #include int main(void) { int x = 1; { int x = 2; /* this x 'shadows' the other one? */ printf("%d\n",x); /* it's just a different variable */ } printf("%d\n",x); return 0; } Incidentally, gcc -Wall doesn't give any warnings with that program, since it's a perfectly reasonable thing to do. The only reason Ruby would warn is because it's not backwards-compatible. I would imagine that eventually this warning would be turned off. Regards, Brian.