-
Notifications
You must be signed in to change notification settings - Fork 372
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
Reader macros aren't #1230
Comments
Something like Clojure's tagged literals #1046 might be easier to implement. Those aren't true reader macros in the Common Lisp sense either. But Hy is more like Clojure than Common Lisp. |
Definitely, I think tags of that sort wouldn't be hard, since the macro gets run at the same time as ordinary macros. |
See also #1042. I don't know that Perl-style heredocs would work well in a Lisp, but maybe something like Lua's long brackets could work. If we had the better string syntax, then we could apply a tag to invoke an arbitrary reader/interpreter/compiler on a string containing any language we like. I think this would get us most of the power of reader macros, but perhaps there's more I haven't thought of. |
I think I'm going to make a PR to just rename them to "sharp macros" (and make the documentation less misleading). The extension to symbols longer than 1 character can be done later if desired. |
For a long time, Hy has had a feature we call "reader macros", but they're not actually reader macros, just regular macros with an unusual syntax for calling them. A reader macro is a macro that is called at read-time, and hence can change how raw characters of the source are parsed. It's provided with raw text as arguments. An ordinary macro, on the other hand, is called after the text has already been parsed into s-expressions. It's provided with s-expressions as arguments.
Real reader macros would be nice to have, but they would be hard to implement (see #722, which is over 3 years old and probably won't get closed soon). In the meantime, I think we're long overdue for not misleading users about our so-called reader macros. I see two options:
#
).defreader
would then bedefsharp
or something.The text was updated successfully, but these errors were encountered: