Skip to content
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

Add Clojure tagged literals or similar #1046

Closed
gilch opened this issue Apr 14, 2016 · 2 comments
Closed

Add Clojure tagged literals or similar #1046

gilch opened this issue Apr 14, 2016 · 2 comments
Labels

Comments

@gilch
Copy link
Member

gilch commented Apr 14, 2016

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.

@gilch gilch added the feature label Apr 14, 2016
@Foxboron
Copy link
Member

That would be very trivial actually. We decided on one character when i wrote it a looonngg time ago.... maybe @olasd still remembers why.

@gilch
Copy link
Member Author

gilch commented Nov 26, 2016

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?

=> #%42
42

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants