84cec642a3
This changes the semantics of local labels. Previously, local labels were just shorthand for writing out `name.local`, which meant if there were multiple sections named "name", there could potentially be name collisions. This commit adds a unique numeric suffix to each section's ID string. This guarantees that locals in one section won't interfere with those in a different section.
53 lines
635 B
Plaintext
53 lines
635 B
Plaintext
'Slightly contrived example: two routines
|
|
'using the same local label ".loop"
|
|
:run_w
|
|
#walk w
|
|
:.loop
|
|
#try w stop
|
|
#.loop
|
|
'
|
|
:run_e
|
|
#walk e
|
|
:.loop
|
|
#try e stop
|
|
#.loop
|
|
'
|
|
:stop
|
|
#walk i
|
|
---
|
|
'Using locals before any globals are defined
|
|
:.loop
|
|
#take gems 1 .break
|
|
#.loop
|
|
:.break
|
|
---
|
|
'Multiple sections with the same name
|
|
#end
|
|
:touch
|
|
Trying to sell you some ammo...
|
|
#take gems 10 .skip
|
|
#give ammo 10
|
|
:.skip
|
|
#zap touch
|
|
#end
|
|
:touch
|
|
Trying to sell you some torches...
|
|
#take gems 15 .skip
|
|
#give torches 5
|
|
:.skip
|
|
#restore touch
|
|
---
|
|
'Multiple locals with the same name
|
|
#end
|
|
:repeat3
|
|
:.z
|
|
:.z
|
|
:.z
|
|
#take gems 1 .skip
|
|
#give score 1
|
|
:.skip
|
|
#zap .z
|
|
#.z
|
|
:.z
|
|
|