Open GWRon opened 3 years ago
Why would this ever work?
Prepending a dot means to access something from the global (top-level) scope. You wouldn't need it in this example, but it would allow you to access the variable even if it is hidden, e.g. by an identically named local variable. The code above should work, and it does in legacy BlitzMax, but not currently in NG.
I would clearly call that a syntax error even if the parser accepts it. But for the fact you say that it works classic bmax makes it a bit ambiguous. Even after 20 years, Sibly's parser has some secrets to reveal.
As already explained, the dot allows to access the global scope.
The lengthier test file(s) should show pretty nice what it can be used for - and that it makes kinda sense.
But yeah, surely a bit rarely used ;-)
I would clearly call that a syntax error even if the parser accepts it.
But it isn't a syntax error, just a feature you didn't know. In C++ you can write ::test
to do the same thing, in C# you can use global::test
; in BlitzMax you can use .test
.
this is based on the SCT test: tests/framework/types/global_03.bmx