-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] A predeclared EQUS symbol for "the current global label" #775
Comments
I'm not a fan of this, tbh. The redundancy is fine, imo, and adding this would mean creating/deleting/updating an extra symbol on every label creation. Plus, given that RGBASM strings are managed so poorly, either defining a label within an Closing due to the latter reason. May be worth re-opening later, if there's still a need for it. |
I was expecting this wouldn't need to be updated eagerly, but could reuse whatever access local labels have to their current global scope, only when I might open a PR if I can get it working without UAF or excessive memory allocation. If not, that's a good reason to close this. |
If it's not updated eagerly, how would it handle the lack of scope? |
I had in mind using |
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is undefined if in the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
__SCOPE__ expands to the currently scoped label. It is empty if inside the main scope. Fixes gbdev#775
Note the previous discussion in PR #776. Given that we don't have some expanded multi-level scope system actually worked out, and there'd still be the concept of a top-level current scope even if we did, I'd still like to see |
As soon as multi-level scopes are implemented, what constitutes "the current scope" becomes murky: is it
Even the I recognise the interest in this feature (see my own macros), but I do not want it implemented in a way that will block multi-level scopes, which is another feature that has garnered interest. |
I'd say that "the last label" and "the last top-level label" are separate concepts and could warrant separate definitions. And those are very well defined. |
Alternative syntax proposed in #506 (comment): Mult: ; hl = h * e
ld d, 0
sla h
sbc a, a
and e
ld l, a
ld c, 7
.loop
add hl, hl
jr nc, ..bitNotSet
add hl, de
..bitNotSet
dec c
jr nz, .loop
; At this point:
; - `.` refers to `Mult`
; - `..` refers to `.loop`
; - `...` refers to `..bitNotSet`
; - `....` is undefined
ret I like that it meshes well with nested scopes, also that it's consistent with the declaration syntax, but less that it's kind of cryptic. Thoughts? |
I'd say that's valid for nested scopes, or for when you need to extract a label at a specific level (something that is currently a valid concern already, as we have two levels as it stands). But this doesn't solve the issue of "last label defined", since you'd have to know the level of that label, so that should be separate. |
What's the use case for "last label defined"? All I can think of is "offset from a label in the same section", and |
Any macro that shows a message to the user, for instance. (Also, if we're talking about labels being declarable outside their parents' scopes, |
A macro showing a message to the user seems more likely to want to print the top-level label than any local, imo.
|
The case brought up in #1157 relates to local RAM labels associated to a function (in ROM, naturally), so those would obviously be in separate sections. |
Yes, but I don't see why you'd want the offset between those and something in the ROM section. |
You wouldn't. You'd want the offset between your current address and something, and if your current address is in RAM and |
Between the current address and something in the same section should be covered by |
I like it too! We already lex a |
fasm does it this way too:
|
Note that this means we can't reserve |
For instance,
_GLOBAL
or_SCOPE
. This would be undefined if there is no current globally scoped label.This would be useful to avoid repeating names. I've had multiple use cases for code like this:
Foobar:: mac Foobar
In this case
mac
might be defining more labels that useFoobar
as a prefix or suffix. I like to avoid havingmac
do\1::
to declare the main label itself, since that makesFoobar
's definition harder to find.Or,
mac
could be mentioningFoobar
in some error message. This is useful for macros that don't declare any code/data/labels, but just check assertions about what's already there, like data table lengths or verifying that certain related symbols are defined.The text was updated successfully, but these errors were encountered: