Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Macro naming convension for porth.porth #130

Open
mjdr opened this issue Oct 11, 2021 · 0 comments
Open

Macro naming convension for porth.porth #130

mjdr opened this issue Oct 11, 2021 · 0 comments

Comments

@mjdr
Copy link

mjdr commented Oct 11, 2021

Right now macros in porth.porth refer to addresses of corresponding objects
And they de referenced as needed

Proposal:

Template for names of addresses:

&{name}

So, macros that gets value of single cell object can be implemented like this:

macro {name}
  &{name} @64
end

And for writing single cell values, like this (not sure about syntax):

macro ={name}
  &{name} !64
end

With #129 this code

macro push-op // type operand -- 
  ops-count @64 sizeof(Op) * ops +
  dup Op.operand rot swap !64
  Op.type !64
  ops-count inc64
end

transforms into this

macro push-op // type operand -- 
  ops-count &ops[]
  dup Op.operand rot swap !64
  Op.type !64
  &ops-count inc64
end

A lot more readable

@mjdr mjdr changed the title Marco naming convension for porth.porth Macro naming convension for porth.porth Oct 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant