why does strict not warn about shaddowing declarations ? 
Author Message
 why does strict not warn about shaddowing declarations ?



Quote:
>of course what happens is that one declaration shaddows the other,
>so the $Y that gets written to is the inner one not the outer one.

>is there a good reason why strict doesn't scream about this ?

The whole point of lexical variables -- indeed, of local variables in
general -- is that you can decide whether a certain piece of your
program works without reference to its environment.  You know that
changes you make elsewhere in the code will not make it stop working
correctly.  You know you can transplant it into a different program, or
call it from a different part of the same program, without it ceasing
to work.

Having several of your functions suddenly fail to compile when you add
a new global variable is somewhat in opposition to this principle.

I once thought that warning or dying on shadows would be a good idea.
I think I was wrong.

DrScheme has a nifty feature which would have helped you find that bug
-- whenever you move the mouse pointer over a variable reference in the
source code editor, an arrow appears connecting the variable reference
to the declaration to which it refers.  (Of course, it works with
Scheme, not Perl.)
--

Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL: http://www.*-*-*.com/ ~kragen/bubble.html>



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. O_OBJECT uses warn() not croak(), why?

2. Why, why, why, -w and use strict?

3. works without strict but not with why ????

4. why not use(strict)?

5. strict variable declaration in subroutines

6. use strict refs not so strict?

7. Why the warning message

8. Why this warning?

9. Why no warning with -w

10. Why does this give a warning!

11. Warning disappears when require goes inside BEGIN - why?

12. use strict: why?

 

 
Powered by phpBB® Forum Software