-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I like the discoverability of the macro namespace. Having it named that is helpful. The first line of a Lissp module is almost always going to use alias, prelude, or some equivalent macro, and it has to be spelled out completely, like (hissp.._macro_.prelude), which seems a little verbose/ugly. After that, fully qualified macro names are mostly hidden, even in the compiled output (since macros have expanded by then), however, the compiler does insert a comment with the macro name.
Possible alternatives:
_macro_(Status quo, for comparison.)(hissp.._macro_.prelude)
__macro__Even longer. More obviously a magic hook, but such names are technically reserved for Python proper. There's a chance it could steal it one day.(hissp..__macro__.prelude)
_mac_Not too different. Probably not worth the reduced clarity.(hissp.._mac_.prelude)
_m_Much shorter, but still not pretty.(hissp.._m_.prelude)
_MSome risk of collision for a name this short without the trailing underscore, although being "private" to the module with the leading underscore makes this less of a concern. Almost looks like Hungarian notation.(hissp.._M.prelude)
QzOmitting the trailing underscore is questionable but it looks better. Macros themselves aren't necessarily private, but their namespace shouldn't be directly imported almost ever.Qzhas precedent as being meaningful to the compiler proper, not just the reader/munger (QzMaybe_). It is unlikely to collide with anything not from Hissp, but makes star-importing one Hissp module into another kind of broken, without the explicit__all__. Star imports are questionable practice (and__all__may be good practice, and may be easier with macro support), but I don't want to prohibit them. This is probably a bad idea.(hissp..Qz.prelude)
!orQzBANG_(hissp..!.prelude)I think this one looks the best, but again, no leading underscore.hissp..QzBANG_.prelude:Hebigo isn't munged, so it might look like this.
_!_QzBANG_(hissp.._!.prelude)With the underscore.hissp.._QzBANG_.prelude:Kind of cryptic compared to status quo, but not much worse._Mwouldn't have this problem.
_-- or_Qz_(or_QzH_, given Consider munging-asQzH_instead ofQz_#256)(hissp.._-.prelude)Not obviously better than_M. Not as pretty as_!, I think.hissp.._Qz_.prelude:Not really worse than the status quo, but cryptic.hissp.._QzH_.prelude:Maybe slightly worse, and still cryptic.
_M seems best.
Another option for Lissp is a reader macro. A fully qualified function can be used at read time, even if it's not in a macro namespace, but it could expand to a fully qualified macro invocation. Prettier things like
hissp..prelude#:Only does the prelude.:is a dummy arg to avoid the longer*=#().(hissp..!#prelude)Prependshissp.._macro_.. Like a fully qualified alias.(hissp..!#alias ! hissp._macro_)Same.hissp..!#preludePrepends and invokes. Maybe less flexible.hissp..!### alias ! hissp._macro_Same, but with more read-time args.hissp..alias## ! hissp._macro_Only does aliases.
could be possible by adding reader macro functions to hissp.__init__, even without changing the name of the macro namespace. Some of these variants would work in the EDN Hissps. This wouldn't help Hebigo at all (no custom reader macros), but it (currently) has ! as a built-in alias of hebi.basic.._macro_., which could have something similar added.