-
Notifications
You must be signed in to change notification settings - Fork 371
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 a macro for punning keyword arguments #1686
Conversation
Putting this in core seems premature. It's an experimental macro not even based on anything from Clojure or Common Lisp, that means it belongs in contrib. I don't imagine I'd use this enough to justify it, but if it proves popular we could then move it to extra. |
(HyExpression (reduce + (gfor x body | ||
(if (and (keyword? x) (.startswith x.name "^")) | ||
[(HyKeyword (cut x.name 1)) (HySymbol (cut x.name 1))] | ||
[x]))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definition isn't indented properly. Make sure it passes parlinter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked you to stop this. Twice. Then you insulted me about it. Please don't comment on my indentation again.
I wouldn't say it's experimental (it's a very simple macro), and the inclusion criteria for contrib and extra have nothing to do with Common Lisp or Clojure. |
What's the inclusion criteria for |
We never decided on any. In practice, it contains macros that are short and are of general use, and we should probably stick to that. |
@gilch To be clear, are you vetoing this as-is? |
Yes, vetoed.
I sure would! By "experimental" I don't mean only to say that we're not sure if it meets the intended spec, but also that we're not sure if the spec is even what we want. There should be one-- and preferably only one --obvious way to do it. The above is a good argument for standardizing general-use functions and macros so obvious that they get invented independently anyway, but in slightly incompatible ways. (Like From Clojure's core. (And from its core syntax and special forms where Hy is lacking, like So far, I'm uncomfortable with the whole approach. Are we sure we want a macro rather than a tag? Yes, a macro is loads better than a compiler extension. But Hy's keyword arguments are already allowed to start with That's why it's experimental. None of this is enough to keep it out of contrib, by the way, with our other experiments. Maybe the broader Hy community will eventually gain enough experience with it to justify promoting it to core. Eventually. Perhaps with changes, though. |
It's clear that lots of time and people and thinking went into previous languages, but none of those things imply that the results are any good. People's decisions are subject to inertia and groupthink, and there's no group so large that anything important is guaranteed to be thought of by somebody in the group. How things have been done previously is not any indiciation as to what should be done.
The distinction doesn't seem important. I could switch it to a tag macro if you'd prefer that.
With mangling, as you just realized and as already tested. It's clumsy, but it's hard to see how the clumsiness will matter considering the sheer weirdness of beginning a function parameter's name with a caret, and the coincidence of wanting to use
To be clear, I'm not against mangling nicknames for ASCII characters, just the absence of a clear marker of whether a name has been mangled (which is currently the
I'd anticipated this problem you thought of, but if you can think of any other potential problems with the macro, by all means mention them and I can fix them and add tests. It's appropriate to hold up a PR for known problems, but not for problems they might have but we haven't even thought of yet. |
@gilch Have you thought of any potential problems? |
@gilch So what's the word? Do you want it as a tag macro instead? |
Although I've known of Hy for a while, I haven't used it "in anger" much, so I'm still a tyro. My perspective comes from using other Lisps, so for whatever it's worth: Since (apply dict [:monitor monitor :verbose verbose :cv-folds cv-folds])
(pun dict :^monitor :^verbose :^cv-folds) What if (dict #** (pun monitor verbose cv-folds)) |
In that case, Can I ask why you find yourself missing |
Right, it is more characters, but it would follow what seems to now be the encouraged pattern of using
Because I use |
Closes #1119.
Replaces #1685.