Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Implement a Lisp macro system

Name: Anonymous 2015-05-31 12:09

/prog/, do you know of a tutorial or a paper on implementing a Lisp macro system from scratch? It could be Scheme macros, it could be really simple macros, anything would be helpful.

Name: Anonymous 2015-05-31 13:42

>>3
The problem is that macros can call functions and functions can call macros. After parse, I don't even have a valid AST, because it's got arbitrary macros that need to be expanded first. So the compiler would first need to find macro definitions (only the toplevel definitions or all of them? Haven't decided yet), then find all functions called in those macro definitions, then try to expand all the macros called in the bodies of those functions, etc etc. Compiling Lisp seems to be a horribly undecidable problem.

For example, how should I handle a situation like this?

(defmacro (mac-1)
(func-1))

(defmacro (mac-2)
(func-2))

(defun (func-1)
(mac-2))

(defun (func-2)
(mac-1))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List