4 ms·
I don't believe anything that can be written with unhygienic macros can't be written in a hygienic macro system. Macros written using implicit renaming is writt
by bjoli 6y ago
I don't believe anything that can be written with unhygienic macros can't be written in a hygienic macro system. Macros written using implicit renaming is written just like CL macros, and with enough libraries you can do something similar with syntax-case.
Heck, implementing an unhygienic defmacro over a regular lambda is something like 7 lines of syntax-case. In guile you could even use lambda* to get optional and keyword arguments.
- Jtsummers 6y agoSo, again, I don't think I know for certain why I'd want to do this, but here's an example of different behavior with the two: (defmacro my-not (x) `(not ,x)) (flet ((not (x) x)) (my-not 't)) In a hygienic macro system, that local definition of not will have zero impact on the execution. In an unhygienic macro system, that local definition is used instead of what the macro writer probably intended. That's a stupid, trivial example that would hopefully never be written. My best guess for wanting something like this, per my previous comment, would be a system like SCREAMER or SERIES which could make use of this local redefinition to produce a different-than-standard behavior. How would you write a hygienic macro which would make use of the local redefinition of not without also having to pass the redefinition to the macro?
- fiddlerwoaroof 6y agoThis is right, but shadowing symbols in the CL namespace like this is usually not allowed: the compiler is free to optimize a lot of these things by inlining definitions and such, so this may not do what you think (unless you shadow CL:NOT)
- junke 6y ago"Usually not allowed": rather the behavior is undefined, it is not a conforming program. (and in practice the error is "Lock on package COMMON-LISP violated when binding NOT as a local function", you can lock your own packages too if you want). Also, you generally mind your own symbols, you don't rebind symbols from other packages (hygienic macros are more useful when you only have one namespace).
- bjoli 6y agoI would use syntax case and introduce unhygienic bindings. That is the deal with all low-level hygienic macro systems: hygiene by default. Break hygiene explicitly. In syntax-case that would be (datum->syntax syntax-object-where-i-want-to-introduce-binding 'not)
- deleted 6y ago[deleted]