in reply to Re^6: Help! My variables are jumping off a cliff!
in thread Help! My variables are jumping off a cliff!
I think we're all agreed that declaring the same var twice in the same scope is a mistake...
I certainly don't agree that it's necessarily a mistake, even in the case that Dave Mitchell demonstrated, where the compile-time lexical binding may differ across closures. You can't analyze that statically and get the right answer all of the time!
Separate the act of assignment from the act of declaration and think about the code again.
Then separate the judgment of "Would I write code this way?" from "This is a practice so worth discouraging that it needs special casing in the compilation process."
except for all the other languages that consider double-declaration like this a fatal flaw
Pure functional languages consider mutable variables a fatal flaw. I don't see how that matters either.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Help! My variables are jumping off a cliff!
by BrowserUk (Patriarch) on Feb 27, 2012 at 04:54 UTC |