Closed ktodyruik closed 8 years ago
That example is out of date. Sorry! It's my fault.
Almost all of the code examples are set up to be automatically tested (with tests-ex-markdown), but that one seems to have slipped through. I'll fix that and review what other examples might be untested.
For now, test.ls
contains a similar test, which definitely works:
(macro mean
(lambda ()
(var args
((. this list apply) null ((. Array prototype slice call) arguments 0)))
(var total ((. this atom) ((. (. args values length) toString))))
(return `(/ (+ ,@args) ,total))))
(mean 1 2 3)
That compiles to this:
(1 + (2 + 3)) / 3;
Why this is written differently now: Macros used to return arrays. Since the macro input and output formats became the same, they have returned objects with type
- and value
-properties, not arrays. That's why ,@
(unquote-splicing) failed for that example. Just in case, I'll make the error text clearer too.
Thanks for reporting. I'll post progress updates.
Hi,
I've been getting some errors in my macros. It's likely I'm making mistakes, so I tried an example from the documentation. I seem to be having trouble with @,
This macro:
Throws and error when I compile it. Here is the error: