Closed porky11 closed 6 years ago
Some question: Is it even possible to expand macros manually currently? (something like macroexpand
or macroexpand-1
)? This may be useful when writing macros for calling functions and macros in different ways (like for #155). Currently safe wont be called for macros, when It would be done, there needs to be defined a version for every macro, else
(safe (let ((x \ 1)) body))will expand to
(safe-let (safe ((x \ 1)) (safe body)). When macro-expanding is possible, only for special forms, special behaviour of which parameters will be set
safe` needs to be called. The macros could be expanded then, and handeled like safe specialforms and function calls.
Thanks for this. There was a problem with macros receiving evaluated arguments, rather than unevaluated arguments, which has now been fixed. The output of the test program is now like so:
$ dalec test.dt
int
this-should-not-be-printed
1.0
macro?
$ ./a.out
int
not-int
The reason that 'this-should-not-be-printed' appears is that each function/macro argument is fully evaluated during the dispatch process, so as to determine its type. The macro documentation has been updated to clarify this point.
Macros should get the unexpanded DNodes as parameters. If the arguments have to be expanded, they should expand them oneself. Here some example, where this may cause problems: