10-12-2023, 01:00 AM
Code: (Select All)
OPTION _EXPLICIT
f 2
SUB f (x)
DIM x AS LONG
PRINT x
END SUB
Note that the above is perfectly valid. In fact, Option _Explict won't even toss us an error saying "Undeclared Variable" here. It passes the IDE inspection, compiles just peachy fine, and is about the best example of "How NOT to Program" that I can think of.
Why the heck does BASIC allow this type of junk to ever pass muster to even begin with?!
And it that doesn't boggle your brain any, take a look at the extended version of this mess:
Code: (Select All)
OPTION _EXPLICIT
f 2
SUB f (x)
DIM x AS LONG
PRINT x, x!
END SUB
At no point did we declare a variable as x!, yet parameter x defaults to SINGLE, so Option Explicit happily accepts it as being declared as SINGLE, which makes x! valid -- except we can't reference it as X as X is now a local LONG, which is not to be confused with parameterX, which is SINGLE and can be referenced by x! but not x......
Confused yet??