Skip to content
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] Nested label scopes #916

Open
Rangi42 opened this issue Jul 30, 2021 · 3 comments
Open

[Feature request] Nested label scopes #916

Rangi42 opened this issue Jul 30, 2021 · 3 comments
Labels
enhancement Typically new features; lesser priority than bugs rgbasm This affects RGBASM
Milestone

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Jul 30, 2021

(Note this this is independent from the concept of "scopes" for symbols in general, which would allow shadowing of outer symbols and auto-purging when the scope ends; see #342.)

Currently there's only one level of symbol scoping: .local symbols are scoped to their preceding Parent. It might be useful to have more levels, in the manner described by ax6:

..foo to define a label in the second-level nested scope would be some simple syntax that could be used. Like so:

Main:
  dw 1234
: ..label isn't allowed here (nonsensical nested label; no parent)
.foo
  dw 5678
..bar ; defines Main.foo.bar
  dw 9012
.baz ; defines Main.baz (up a level because it only has one dot)
  dw 34567

Naturally, ...label would be a third level, etc. Explicit definitions (.foo.bar, Main.foo.bar:) should also work.

It could autofill each upper level separately: so appending Main..bar there would become Main.baz.bar, appending .baz.qux would become Main.baz.qux (and then appending .baz..spam would become Main.baz.qux.spam).

@Rangi42 Rangi42 added enhancement Typically new features; lesser priority than bugs rgbasm This affects RGBASM labels Jul 30, 2021
@Rangi42
Copy link
Contributor Author

Rangi42 commented Sep 15, 2022

One use case:

wShadowOAM::
    for i, OAM_COUNT
        .obj{d:I}::
            ..y:: db
            ..x:: db
            ..tile:: db
            ..attr:: db
    endr

That lets you do ld [wShadowOAM.obj2.tile], $42.

@Rangi42 Rangi42 modified the milestones: v0.9.0, v1.0.0 Nov 3, 2023
@Rangi42 Rangi42 removed this from the v1.0.0 milestone Aug 6, 2024
@Rangi42
Copy link
Contributor Author

Rangi42 commented Sep 10, 2024

fasm has this, including ..foo and ./.. functionaity.

@Rangi42
Copy link
Contributor Author

Rangi42 commented Jan 15, 2025

customasm has this as well.

@Rangi42 Rangi42 added this to the 2.0.0 milestone Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Typically new features; lesser priority than bugs rgbasm This affects RGBASM
Projects
None yet
Development

No branches or pull requests

1 participant