samth
2020-9-8 21:59:24

fexprs don’t make macros redefinable — they are a way to have functions be called with the syntax rather than the value of their arguments. redefinability is orthogonal to that.


rokitna
2020-9-9 02:14:51

Your description of fexprs is spot-on, and that’s why they’re a natural consequence of solving the redefinability problem for macros the same way as it’s commonly solved for functions: If you look up a macro’s definition just before you call it (i.e. at run time) so that you’re sure to get the latest one, and if you pass it the arguments a macro expects you to pass it (i.e. unevaluated ones), then the fact that you’re passing around unevaluated arguments at run time means you have a distinctly fexpr-flavored computation model. (Or as some people would put it, you have a Lisp interpreter.)

Conversely, if a language supports fexprs and has a mutable top-level environment, it probably already solves the macro redefinition problem this way.

This consonance of implementation techniques makes it hard to call the two systems “orthogonal,” even if macro redefinition doesn’t strictly depend on this particular implementation technique.

Here’s someone talking about how macro redefinition (or more specifically, forward reference) can lead intuitively to fexprs: https://calculist.blogspot.com/2009/01/fexprs-in-scheme.html?m=1\|https://calculist.blogspot.com/2009/01/fexprs-in-scheme.html?m=1

And here’s a question on Reddit about how to make macro redefinition into a nicer experience, to which someone in the replies suggests using an interpreter: https://www.reddit.com/r/lisp/comments/dv5ici/redefine_functions_on_macroredefinition/\|https://www.reddit.com/r/lisp/comments/dv5ici/redefine_functions_on_macroredefinition/


samth
2020-9-9 02:24:39

As Dave (a friend of mine) points out in the comments of that post, “use an interpreter” doesn’t mean anything here. As to the actual post, I just disagree what he suggests is “fexpr-like”. The point of a fexpr is that it’s a value.


rokitna
2020-9-9 06:55:42

Ah, I think an fexpr being first-class is just incidental in this situation. So I see why you would have called fexprs orthogonal here, thanks.