[slang-users] try does not run require
Jörg Sommer
joerg at alea.gnuu.de
Mon Jun 12 09:14:53 EDT 2006
Hallo John,
"John E. Davis" <davis at space.mit.edu> wrote:
> variable i;
> variable j = 0;
> for (i = 0; i < n; i++)
> {
> variable j;
> for (j = 0; j < M; j++) ...
> }
ACK. This is ugly. But if you specify that only global variables can be
overridden, because they are still accassable through Global->, than this
could not happen.
> and would be suprised to find that j is not 0 at the end of this code
> fragment. For this reason, slang flags the duplicate declaration of j
> as an error.
Right, because in your example a variable within the same namespace is
redefined in an inner scope. But an error in this example:
if (...)
{
variable i;
...
}
...
while (...)
{
if (...)
{
variable i;
}
}
is not really intuitive.
> But it only generates this error when the code occurs in a function.
> It does not do so for global variables, so that code such as
Which is IMO not really consistent.
Have a nice day, Jörg.
--
Roesen's Law (http://www.bruhaha.de/laws.html):
Sobald ein Troll, DAU oder Elch im Lauf eines Threads auf heftige Kritik
stößt, argumentiert er mit der Arroganz des Kritikers. Dies kann auch
vorsorglich erfolgen.
More information about the slang-users-l
mailing list