Is there anything like reader-macros in Newlisp?

Pondering the philosophy behind the language
Locked
Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Is there anything like reader-macros in Newlisp?

Post by Kazimir Majorinc »

I remember that Ted once proposed it, but I do not remember if it was implemented on any way.

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: Is there anything like reader-macros in Newlisp?

Post by TedWalther »

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Is there anything like reader-macros in Newlisp?

Post by Lutz »

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
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Is there anything like reader-macros in Newlisp?

Post by cormullion »

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
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: Is there anything like reader-macros in Newlisp?

Post by TedWalther »

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Is there anything like reader-macros in Newlisp?

Post by Lutz »

I thought your reader macros only did transformations on already well-formed newlisp syntax?
yes, on wellformed s-expressions.

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: Is there anything like reader-macros in Newlisp?

Post by TedWalther »

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.

Locked