-
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
Remove some redundant keywords #880
Conversation
Not used in Hy after removing redundant keywords. Likely to encourage similar problems in the future.
👍, except for (defmacro-alias [condᵉ conde] [&rest cs]
(with-gensyms [s c]
(let [[ncs (__subst-else cs)]]
`(with-monad logic-m
(fn [~s]
(m-plus (map (fn [~c]
((apply all ~c) ~s))
[~@ncs])))))))
(defn-alias [firstᵒ firsto] [l a]
(fresh [d]
(consᵒ a d l))) Granted, the number of people who do that are few, but when you want to give a function a hy-ish, perhaps unicode name, and still want to allow python people to use it without tearing their hair out, these macros are handy. And fun. I agree they don't have much use, but they aren't completely redundant. |
I'd also like the alias functions to stay. They are usefull even tho the core lib won't be using them much. |
Just to say: I like having both |
👍 on keeping the I also seem to remember there being a slight difference between |
...
Maybe I should just move them to contrib. It would keep the core more focused, but you could still import (require) them if you want. On the other hand, it's pretty easy to alias a function even without the macro: (def firsto
(defn firstᵒ [l a]
(fresh [d]
(consᵒ a d l)))) This way it's clear which is the standard function name and which is the alias. I feel like there ought to be a similar way to alias a macro after it has been defined, but it doesn't look easy. The |
See, I knew the other groups would be more controversial. This pull (so far) only targets the first group, and we don't have to agree to fixing the other two before merging this part. We can still talk about them though. As for the second group, I'll admit to using the easier-to-type aliases Even if you're not convinced by the following, can we at least get rid of Correct me if I'm wrong about this assumption, but Python keywords have to be reserved in Hy, because Hy compiles to Python and can be imported from Python. They don't have to mean the same thing in Hy as in Python, though this can get confusing. I am unconvinced by the argument that The case where Boolean literals get used the most is in testing. If you're testing at the REPL and just need a generic truthy or falsey value, admit it, you're going to use Unit tests, on the other hand, also serve as a kind of documentation. It's worth making them readable. Now if we decide that it's idiomatic in Hy to use I am also unconvinced by the argument that true, false = True, False The first group in the pull (which we do seem to agree on) breaks stuff a lot harder than this. Yes, the Grand Language Cleanup will break stuff. Best get it over with now. If removing There's a better argument for keeping |
I'm OK with purging true false null and nil.
|
Ok, lets get this rolling: @gilch, can you do the contrib move? Or I can merge this as-is, up to the prior commit, and do the move myself. |
The throw, catch, progn, defun, lisp-if and lisp-if-not aliases are going away, as per hylang/hy#880, add rules to grand-cleanupᵒ that suggest the correct symbol names. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Ref #240 in the Grand Language Cleanup. This is not enough to close the issue, but it helps. The redundant keywords I am aware of in Hy are:
This pull request only touches the first group, likely to be the least controversial. The second group may be a bit more difficult to fix. The third group has slightly different behavior/convention, so may be harder to unify.
Removed:
throw
Rationale:
raise
is a Python keyword, and thus reserved anyway. This reduces the number of reserved words in Hy, while the other choice would not. It is also less confusing to Python programmers.Removed:
catch
Rationale:
except
is a Python keyword, same as above.catch
was popular, perhaps because it's shorter, but when choosing between Python reserved words and equivalent Clojure words, Hy must choose Python's words, or redundancy in reserved words remains.Removed:
progn
Rationale:
do
is shorter, andprogn
was barely ever used in Hy anyway; Clojure forms are more favored by the community than Common Lisp's.Removed:
defun
Rationale: as above,
defn
is shorter, used more, and Clojure, rather than CL. (This commit also removesdefun-alias
.)Removed:
lisp-if
andlisp-if-not
Rationale:
lif
andlif-not
are shorter. A weak reason, but had to break the tie somehow. These aren't used that much anyway.Removed:
defn-alias
anddefmacro-alias
Rationale: After removing the above redundancies, these are no longer required in Hy itself. They are also likely to cause similar redundancy issues in the future, in Hy and elsewhere, thus were bad for the health of the Hy ecosystem.