9.5. Escaping the current scope or namespace

To escape the current scope, use @ to reference the root scope. In the following code '@myLabel' access the myLabel label in the root scope:

.label myLabel = 1
   .label myLabel = 2

   .print "scoped myLabel="+ myLabel //<-- Returns 2	
   .print "root myLabel="+ @myLabel  //<-- Returns 1

The same can be done for functions, macros and pseudo commands. So the following example will print 'root' not 'mySpace':

.function myFunction() { .return "root"}
.namespace mySpace {
   .function myFunction() { .return "mySpace" }
   .print @myFunction()

You can also put new entities in the root scope when defining them from within another scope:

   jsr outside_label 
   lda #0
   sta $d020
   sta $d020


   .label @x = 1234
   .var @y= "Hello world"
   .const @z= true

.print "x="+x
.print "y="+y
.print "z="+z

Or for functions, macros or pseudo commands, here shown in a library file:

#import "mylib.lib"

.print myFunction()

/* File mylib.lib */
.filenamespace MyLibrary

.function @myFunction() { 
   .return 1

.macro @MyMacro() { 
   .print "Macro Called"

.macro @MyPseudoCommand { 
   .print "PseudoCommand Called"