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

[request] treat macro parameters as local symbol references #31

Open
antis81 opened this issue May 13, 2021 · 0 comments
Open

[request] treat macro parameters as local symbol references #31

antis81 opened this issue May 13, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@antis81
Copy link
Contributor

antis81 commented May 13, 2021

(Referring to current "dev" branch here.)
Should macro parameters (assignments in braces) in bass be treated just like macro-local references?

ACME example (suitable as a test):

!macro inc_store ~.var, ~.call {  ;no braces in ACME
   .var = .var+1  ;var_1 = 43
   jsr .call
}


;zeropage
!section "zp", start=0x0
*=0x2
stored_result: !byte 0

!section "calls", start=0x1234
var_1 = 42
call:
  .store:
     lda #var_1
     sta stored_result
     rts

; start of program
!section "code", start=*
inc_store(var_1, call.store) ;-> stored_result = 43
; do something with stored_result
inc_store(var_1, call.store) ;-> stored_result = 44
; do more with stored_result

Can't we treat all macro parameters by reference and as well imply those are macro-local?

Macro in bass according to the above example:

!macro inc_store(var, call) {
  ; defines:
  ;   __macro_0.var = ~var_1  ; reference to global label
  ;   __macro_0.call = ~call.store
   
  .var = .var+1  ;var_1 = var_1+1 -> breaks the "__macro_0" scope)
  jsr .call
}

💡 This can solve/replace the "shadowed symbol" list (solve it for good!?).
💡 The main issue is with global labels inside macros producing unwanted side effects (e.g. overwrite the __macro_<ID> label).

@antis81 antis81 changed the title Make macro parameters local to the macro [request] Make macro parameters local to the macro May 13, 2021
@antis81 antis81 changed the title [request] Make macro parameters local to the macro [request] treat macro parameters as local symbol references Jun 4, 2021
@sasq64 sasq64 added the enhancement New feature or request label May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants