| There have been posts about the qi language before, but one thing that was always neglected was its cool macros. From the tutorial:
The system function macroexpand is applied to all inputs typed to
the top level and to every element of every file loaded into Qi. By
default, macroexpand is defined as the identity function. However
the macroexpand function can be redefined to allow the user to
define her own shortcuts or notational styles. A simple
macroexpansion can be written that enables arithmetic operations to
be written in infix notation.
(define macroexpand
[X Arith Y]
-> [Arith (macroexpand X) (macroexpand Y)]
where (element? Arith [+ - * /])
[X | Y] -> (map macroexpand [X | Y])
X -> X)
(tc +)
(define factorial
{number - -> number}
0 -> 1
X -> (X * (factorial (X - 1))))
factorial : (number - -> number) In arc, to do something like this, you have use anarki's defcall. Could ark adopt a macro expansion feature like this? |