|Ted Walther||On Newlisp forum, Ted Walther recently proposed introduction of user defined reader macros in Newlisp. User defined reader macros already exist in Common Lisp and some dialects of Scheme. Built-in, but not user defined reader macros exist in Clojure, and to lesser extent in Scheme and even Pico Lisp. Newlisp has no reader macros at all.
Ted Walther's main reason appears to be ability to use other languages in combination with Newlisp.
Example he posted was:
(add-reader-macro 'c-lang) (add-reader-macro 'sql-lang) (add-reader-macro 'html-lang) (println "hi") (C printf("foo%d",1); i++; ) (sql SELECT * FROM ,(amb "table1" "table2") ) (html <h1>foo</h1> ,(generate-some-tables)) )
My answer on Newlisp forum is republished here.
I think reader macros make writing code (programming) more friendly, but writing code that processes code (metaprogramming) more difficult.
I do not think that "one who does not want to use reader macros shouldn't use them" is enough. What would happen if someone writes useful library that uses reader macros? Programmers will start to use it. Theoretically, we can remember both new syntax and how it translates into normal Lisp, but in reality, we can only remember and understand limited amount of information; especially if we use Newlisp irregularly. So we'd start using that library, and later more and more of Lisp as any other language, without understanding how to process code.
This practice would, in turn, influence future development of the language. Although Lutz Muellermakes decisions, these are made on the base of the perceived problems and discussions by other programmers.
I could admit that finally, it is not known whether metaprogramming is good idea and that I only believe it is good idea. The failure of Lisp dialects to establish itself as a mainstream language is not a good sign, but recently it appears that Ruby users practice metaprogramming a lot. Any case, metaprogramming is differentia specifica of Lisp; if it is bad idea, Lisp itself is failure. And if it is good idea, it is comparative advantage of Lisp that should be promoted and not discouraged.
From my point of view, following syntax looks OK:
(load "c-lang") (load "sql-lang") (load "html-lang") (println "hi") (C "printf(\"foo%d\",1); i++;") (sql (append "SELECT * FROM" (amb "\"table1\"" "\"table2\""))) (html (append "<h1>foo<\h1>" (generate-some-tables)))
It is understandable why Ted likes his syntax better. Back while I used PLT Scheme, I used °s-expr instead of (println 's-expr "=" s-expr) equivalent. It was good for debugging, it was enough to insert or delete one ° before suspicious expression. Reader macros can be fun. However, Ted can implement his own, private preprocessor - on that way, whole thing is interesting and challenging private experiment, and not a language policy.
(preprocess (add-reader-macro 'c-lang) (add-reader-macro 'sql-lang) (add-reader-macro 'html-lang) (println "hi") (C "printf(\"foo%d\",1);" "i++;"))
Of course, Ted was aware of that, his opinion is that reader macros are generally useful. (I wrote about preprocessing in this blog previously, in posts EVALUATION IN TWO STAGES and MACROCALL.)