Is there anything like reader-macros in Newlisp?

Started by Kazimir Majorinc, March 04, 2011, 06:10:45 AM

Previous topic - Next topic

Kazimir Majorinc

I remember that Ted once proposed it, but I do not remember if it was implemented on any way.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

TedWalther

#1
Lutz has said "no way".  Perhaps you wish to implement them, Kazimir?  If the implementation didn't impact performance, perhaps he would be amenable.  Especially if it could be done in 100 lines of code or so.  I suspect 500 lines of code max.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#2
Yes there are! Look into the function "reader-event" in the manual and also into the standard module macro.lsp which has a more sophisticated implementation than the simple manual example.



This does macro expansion during loading - translation in s-expressions - of newLISP source.

cormullion

#3
What's a reader macro? Is it just a pre-processor, like the reader-event already in newLISP (since 2009?), or something very different?



I googled this, and got your article as the first hit, Kazimir! :)

TedWalther

#4
Lutz, my understanding of reader macros is that they allow you to alter the syntax of the language?  I thought your reader macros only did transformations on already well-formed newlisp syntax?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#5
Quote I thought your reader macros only did transformations on already well-formed newlisp syntax?


yes, on wellformed s-expressions.

TedWalther

#6
Thanks Lutz, that is what I thought.



Kazimir, the reader-macros currently in newlisp don't support one of the things I wanted; the ability to embed other languages in newlisp code.  With recursion.  I wanted to embed perl inside newlisp inside C inside newlisp... etc.  Maybe add some ,@() syntax.



But newlisp is usable as is; I've been having to rework my mini-languages to be good sexps.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.