Confused about Strict and Local

BlitzMax Forums/BlitzMax Beginners Area/Confused about Strict and Local

xMicky(Posted 2005) [#1]
Strict is described in the BlitzMax documentation only to make errors out of auto declared varibales, forcing us to declare variables properly before using them. But "Strict also has unexpected influence on the range of "Local"-declared variables:

Strict

For Local z:Int =1 To 5
DebugLog "1"
Next

For Local z:Int=1 To 5
DebugLog "2"
Next

No problems so far. Now remove Strict:

For Local z:Int =1 To 5
DebugLog "1"
Next

For Local z:Int=1 To 5
DebugLog "2"
Next

Run this, and you get the Compile Error Message: "Duplicate Identifier "z". Seems, as if "z" isn't Local anymore if you remove "Strict" ! But this is not described such in the documentation neither under "Strict" nor under "Local". And why should "Local" be disabled if you do not use "Strict" ? Is it a bug, or is it a concept, I haven't understood yet ?


Dreamora(Posted 2005) [#2]
It is not disabled
But there is no local scope anymore without strict so a definition within a scope exists outside as well ... don't ask me why, I do not like this total insane "non strict" behavior as well ... on the other side I don't program outside of strict anyway ...


Cajun17(Posted 2005) [#3]
From what I can tell when you're not in strict mode loops and control structures are considered the same scope as the function they're in.

So loop counters stay with you until you leave the function. This is a BASIC concept I think.

Here's a little test I did
Print "For Loop"
For Local x=1 To 5
	Print x '1-5
Next
Print
Print "After for loop: error in strict mode - out of scope"
Print x '6
Print

Function tFunc1()
	Print x '0
End Function

Function tFunc2()
	Local x=3
	Print x '3
End Function


Print "atempt to access x within a function"
tFunc1()
Print "make a new x within a function"
tFunc2()

Print "After funcs"
Print x '6


I don't program outside of strict either. I need all the error catching help I can get.