corth-lang / Corth

A self-hosted stack based language like Forth
MIT License
7 stars 1 forks source link

Macro arguments #54

Open HuseyinSimsek7904 opened 5 months ago

HuseyinSimsek7904 commented 5 months ago

Currently, macros just expand without being able to take arguments like they do in other languages like C or C++. Arguments can be implemented with the following syntax:

macro smart-list64:init list-name starting-size in  // list-name and starting-size will expand to the argument
  memory list-name sizeof ptr in
    starting-size list64:init list-name !64
endmacro

macro smart-list64:_end list-name in   // list-name will expand to the argument
    list-name list64:mfree drop
  end
endmacro