newLISP Fan Club

Forum => Whither newLISP? => Topic started by: Kazimir Majorinc on March 04, 2011, 06:10:45 AM

Title: Is there anything like reader-macros in Newlisp?
Post by: Kazimir Majorinc on March 04, 2011, 06:10:45 AM
I remember that Ted once proposed it, but I do not remember if it was implemented on any way.
Title: Re: Is there anything like reader-macros in Newlisp?
Post by: TedWalther on March 04, 2011, 10:36:21 AM
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.
Title: Re: Is there anything like reader-macros in Newlisp?
Post by: Lutz on March 04, 2011, 11:53:10 AM
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.
Title: Re: Is there anything like reader-macros in Newlisp?
Post by: cormullion on March 04, 2011, 12:49:56 PM
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! :)
Title: Re: Is there anything like reader-macros in Newlisp?
Post by: TedWalther on March 05, 2011, 11:45:56 AM
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?
Title: Re: Is there anything like reader-macros in Newlisp?
Post by: Lutz on March 05, 2011, 01:59:45 PM
Quote I thought your reader macros only did transformations on already well-formed newlisp syntax?


yes, on wellformed s-expressions.
Title: Re: Is there anything like reader-macros in Newlisp?
Post by: TedWalther on March 06, 2011, 11:13:48 AM
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.