-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rethink reader macros #174
Comments
One illustration of why the current inject isn't sufficient, and why we'd need an
|
Aliases already check for The one case this can't handle is when you want to use a compiler macro (living in a |
Reader macros originally required fully-qualified names. I've since added unqualified names ending in a hash in the
_macro_
, and seem to be using those a lot more.It's a design goal of Hissp that everything be available in-line without advance imports. This is important for
lissp -c
usage, and any other embedding that just does short snippets. Maybe I should add that to the README. Unfortunately, this isn't possible for the prelude definitions, butlissp -c
does imply the prelude. Fully-qualified names work for all importable runtime objects, and for compiler macros. The original fully-qualified reader macros also fit this requirement.But, it's pretty awkward that using a reader macro that already ends in a hash requires an escape of that hash. E.g.
It would be nicer if
worked, perhaps by assuming the hash is part of the name. Maybe we don't have to require it to live in a
_macro_
namespace anymore, just end in#
. But considerNow this won't work, because it's
ord
, notord#
in builtins. But,still would. Maybe we can stop here.
This is both better and worse. It's nice that we don't have to fully qualify it (although we can), but it's too bad we have to wrap it in (), which could force a line break in standard style.
ord
was never meant to be a reader macro, we're just invoking it that way, so maybe an inject makes more sense.But consider the alias macro
also from the quick start. As a proof of concept, a custom reader macro could be made to work the same way, on any symbol resolvable at read time:
But, we'd have to "import"
as-reader-macro
somehow. The whole point of this form was to make everything available inline without advance imports.One solution might be to extend the built-in inject macro
.#
to accept optional extra arguments, as aliases do.This would allow any read-time resolvable callable to be used as a reader macro, but wouldn't necessarily require a fully-qualified name. This frees up the fully-qualified reader macro syntax to assume the name ends in
#
, so we don't have to repeat it with an escape, with an overhead of only a few characters:.
,!
, and maybe a space. (Not that fully-qualified reader macros were ever short.)The text was updated successfully, but these errors were encountered: