To resolve this problem i propose introducing 'local' labels, which can have identical names inside different 'global' labels. Here's how it works:
Code: Select all
label global_label: # normal label, nothing changed for its behaviour
"..."
label .a: # local label fully identified as global_label.a
"..."
jump .a # local jump, resolved to global_label.a
label another_global_label:
"..."
label .a: # another_global_label.a
jump global_label.a
It is also possible to expand this idea to have no nesting limit (i.e. making possible to have label a.b.c.d and jump to it inside a.b.c scope by simply "jump ...d")
I also found out that it is currently possible to 'nest' labels using indentation, but it doesn't protect from name collisions. It is possible to implement the same mechanism with such nested labels, but since it uses old syntax, it can cause problems with existing code. Also, it is more visual which can sometimes be good, but can also be bad when you prefer all statements to be on same indentation level.
I already have half-working implementation, but i thought to post proposal here for discussion first.
What are your thoughts on this?
PyTom, would you accept such feature?