You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our reader macros have capabilities similar to Clojure's tagged literals, but Hy's are limited to a single character after the dispatch character #. In Clojure, it can be an arbitrary symbol after the #. One-character macros make sense for something that gets used all the time, or for DSLs where something has to be repeated a lot. But for general user uses, it could be nicer to use a more descriptive name.
I'm not sure how hard it would be to adapt Hy's reader macros to read a symbol instead of a character.
The text was updated successfully, but these errors were encountered:
I can think of one possible reason to restrict it to one character. Say we have a simple an example reader macro:
(defreader % [x] `(print '~x))
Then, with the current restriction, you can apply the reader macro directly to a symbol, like this:
=> #%Hy!
Hy_bang
But if we allowed longer symbols, Hy would try to look up the %Hy! reader macro instead. This is easy to fix. Clojure simply requires a space in such cases, and Hy already allows this:
=> #% Hy!
Hy_bang
It's probably good style to use a space when applying reader macros to symbols anyway, but what if we applied it to a number instead?
=> #%4242
Again, Hy would look for the %42 reader macro. I think this feels nicer without the space, but I still think the change would be worth it.
Our reader macros have capabilities similar to Clojure's tagged literals, but Hy's are limited to a single character after the dispatch character
#
. In Clojure, it can be an arbitrary symbol after the#
. One-character macros make sense for something that gets used all the time, or for DSLs where something has to be repeated a lot. But for general user uses, it could be nicer to use a more descriptive name.I'm not sure how hard it would be to adapt Hy's reader macros to read a symbol instead of a character.
The text was updated successfully, but these errors were encountered: