4 ms·
Tangential curiosity: S-expression languages with lexical binding seem like they still require context-sensitive codewalkers in order to reliably search for pat
by dasyatidprime 5y ago
Tangential curiosity: S-expression languages with lexical binding seem like they still require context-sensitive codewalkers in order to reliably search for patterns that involve any literal symbol that isn't constrained out of that mechanism¹, don't they? What's your strategy for this, just ignore it and hope for the best, or punt to interactive handling for any cases that look slightly tricky? (Or is that still small enough to count as "few lines"?)
¹ For instance, I believe CL forbids lexically binding symbols from the CL package in ways that might conflict with the original definitions. But if you want to find uses of a particular library call from some other non-special package in a sound way, then you have to assume someone might flet that name, due to the way locals work. The underlying codewalker issue is roughly dual to the functioning of non-hygienic macros.
- thelopa 5y agoA naive AST traversal might also interpret some bit of fancy macro DSL as being “regular” code and have a spurious match. Any reliable whole-program source transformation in CL needs to leverage compiler-specific extensions (code walker, environment, etc.).
- dasyatidprime 5y agoI was assuming that at minimum the forms would be fully macroexpanded first (though macrolet is its own problem there). I also have the sense this might be easier in some Scheme dialects, but I don't know any of them well enough to say (thus that's part of my question).
- foldr 5y agoIIRC it's difficult to walk macroexpanded code in Common Lisp because you have to deal with lots of implementation-specific special forms. (Edit) This article has some good info: https://zenodo.org/record/3254669#.YL3-WzYzb2w https://zenodo.org/record/3254669#.YL3-WzYzb2w
- thelopa 5y agoExactly! If you walk the expanded form you have implementation-specific junk to deal with. Also, it may not be possible to map a form post-expansion to a source location. If you walk the pre-expansion form you’re going to get bad results. There’s no winning here unless you have help from the implementation.
- TeMPOraL 5y agoCL being CL, it's important to remember that macroexpansion itself can do anything a real program can. Including writing files, opening network connections, etc.