-
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
Rethink mangling #1173
Comments
By Lisp standards, it's pretty idiosyncratic. For example, Punycode mangling seems to be broken or inactive at the moment, since I never use earmuffs, so I would support that removal. Lisps are traditionally case-insensitive, but Python and hence Hy is case-sensitive, so names in all caps are just fine. The conversions of trailing |
Um, which Lisp are we talking about? I don't code in Unicode much. Do we want emojis and such in Hy identifiers? Or just the written word for other languages? Does Python allow any mathematics symbols? We might want those too. Are the uncommon extra symbols worth making all the mangled symbols impossible for a human to read for non-latin alphabets? If we really want both human readable mangled symbols and emojis, then punycode is out, since it all has to be ASCII alphabetic. We'd have to come up with some other encoding scheme.
Feel free to send that bug, but it's not going to get us anywhere. Backwards compatibility would be more important to them at this point. |
My understanding is that in most Lisps, any character other than the handful that have special meaning (like parentheses and whitespace) are legal characters in a symbol. By contrast, Python 3 permits only characters with certain Unicode character properties. See https://docs.python.org/3/reference/lexical_analysis.html#identifiers |
I created http://bugs.python.org/issue29088. |
It was closed in record time. I would've thought they could create temporary aliases to the old names if backwards compatibility was a concern, but hysterical raisins strike again. |
It's very sad; the right time to change the standard library to uniformly use |
I like earmuffs.
I think this is inconsistent. |
That's how mangling is supposed to work. In Hy, you can write |
Oh, my bad. Thanks ! |
Python since version 3.0 allows much of Unicode in its identifiers. Hy's punycode mangling therefore serves no purpose but to make Unicode identifiers harder to read and Hy-Python interop more difficult. Maybe we should remove this "feature" altogether.
Some Hy features are already restricted to Python 3 or later. Unicode identifiers could be another such feature. It's probably a minority of users that need Python 2 support at this point anyway (and this will only become more true over time). They'll be able to make do with ASCII.
On the other hand, mangling of ASCII characters can be improved. Hy already converts
-
to_
, to allow more Lispy names. Hy code would look very different without this, but it does cause some problems.The other rules are even worse. The earmuff conversion to all caps is of dubious value. It usually indicates a dynamic variable in Lisp, but Hy doesn't have those. (maybe we could add them hylang/hyrule#51) I'd like to remove it.
Hy also converts a trailing
!
to trailing_bang
and a trailing?
to a leadingis_
. But if these characters appear anywhere else, they don't get converted. The AST mostly doesn't care when the results are not valid Python identifiers, but we have no guarantee this will continue. It's already been an issue forgetargspec
#1172 . There are other ASCII characters that are allowed in Hy symbols (like+
) but never get converted at all.Clojure also has to use Java identifiers, but it has a more consistent approach that we might consider emulating. Java's identifier rules are almost as strict as Python 2.
The text was updated successfully, but these errors were encountered: