Visit http://www.thalion-graphics.de/little to download.
It contains more macro system stuff - the old macro code has now finally disappeared,
and with it there go several oddities of the half-hearted solution.
Unfortunately, I can't claim that macro authoring is a strait-forward task at this point.
The API wrapping the compiler internals is not yet completed, so you still here and there
have to immediately use things like the SExpr class (which is particularly ugly, because
it's name denotes the complete absence of LISP knowlege that plagues me ... SExpr has not
really to do anything with LISP s-expressions).
On the other hand, you can now do cool things like using the plain LITTLE inline doc syntax
for macros as well.
To give you an impression of the nastiness of LITTLE macros, here is a sample (taken of the LITTLE system libraries):
(macro when
(doc
"Macro when"
"Syntax:"
" (using little.lang.macro.when)"
" (when ...)"
"This macro expands to the expression '(if (prog ...) nil)'"
"The list of expressions is executed, if is true")
(if ((CC):ge 2)
(let ((expr1 (N))
(expr2 (X 'prog)))
(C expr2)
(R (X (S 'if) expr1 expr2 (S 'nil))))
(E "expected: ' ...'")))
This one already takes use of the doc feature - most lines are inline doc.
Here is a sample of using the macro, taken from little_rep.ltl:
(when (ex:match ((clazz:getsym):tostring))
((little.io.TextOutputStream:out):println "Class <" clazz ">"c))
Keine Kommentare:
Kommentar veröffentlichen