33 ms·
Okay let me get this straight... Are you saying that I don't need to use parenthesis as much in lisp? Instead I could define a few "reader macros" and then imm
by vitiral 4y ago
Okay let me get this straight...
Are you saying that I don't need to use parenthesis as much in lisp? Instead I could define a few "reader macros" and then immediately have a different syntax?
Say if I wanted to change
(if (test-clause) (action1)
(action2))
To
if (test-clause) do (action1)
else (action2)
Is this actually possible inline in lisp, meaning I just need to import a library that implements the if-reader-macro?
- sph 4y agoFor this concept of user-defined languages/DSLs, look no further than Racket.
- fiddlerwoaroof 4y agoThis works in many Common Lisp implementations: https://readable.sourceforge.io https://readable.sourceforge.io
- vitiral 4y agoCool stuff, thanks.
- kazinator 4y agoYes; for isntance see the CMU infix.cl file from the 1990's: https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/syntax/infix/infix.cl https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/... It has test cases at the bottom. like checking that f(a)*=g(b) expands to (setf (f a) (* (f a) (g b)))) The module installs the syntax under the #i dispatch characters; you wrap the infix expression with #I( ... )