Why does this not compile?

BlitzMax Forums/BlitzMax Programming/Why does this not compile?

Russell(Posted 2006) [#1]
Global a

For Local a = 0 To 9
   Print a
Next

If Local is allowed in this case, shouldn't the 'a' be localized to this scope only (and not interfere with the global 'a')?

Just wondering.

Russell


Gabriel(Posted 2006) [#2]
How can it not interfere with a variable which can be read from and written to absolutely anywhere?


Eric(Posted 2006) [#3]
My guess is that Global A and Local A are both inside the Same section of Code. Hence duplicate Identifier.

Locals are meant to be used like
Global A:Int 

Type TFirst
	Field A:Int
	 
	Method Update()
		 
		For Local A:Int   = 0 To 9
   			Print a
		Next
 	End Method 
End Type  



FlameDuck(Posted 2006) [#4]
If Local is allowed in this case, shouldn't the 'a' be localized to this scope only (and not interfere with the global 'a')?
Only in Strict mode where variables are scoped. Like so:
Strict

Global a = 100

For Local a = 0 To 9
   Print a
Next

Print a