-
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
(name :under_scored)
returns "under-scored"
... Why?
#1974
Comments
|
Could we just make an exception for keywords since they should probably stay as close to their string representation as possible anyways? |
It would be better for the user to use whatever combination of |
because as far as i can tell none of those get you the underlying name of the keyword. (str :hello_world) ; => :hello_world
(repr :hello_world) ; => HyKeyword('hello_world')
(mangle :hello_world) ; => hyx_XcolonXhello_world
(unmangle :hello_world) ; => :hello-world
(name :hello_world) ; => hello-world The closest to what jedi wants is |
You can use |
lol didn't know that |
There is one use case I'm starting to think of and that's the ability to normalize dict keys to strings easily. (setv x {"a" 1 :b 2})
(dfor [k v] (x.items) [(name k) v]) ; => {"a" 1 "b" 2}
;; you could write that as
(dfor [k v] (x.items) [(if (keyword? k) k.name k) v]) ; => {"a" 1 "b" 2} Don't know how valid of use case this is to keep |
Generally, it's a mistake to use a HyKeyword instead of a string as a dictionary key. It's too easy to confuse yourself, especially when you're looking at forms like |
yeah, that's why i don't use them myself, but i'm trying to think of reasons to keep |
That seems to go against the intention of the |
Probably the latter. |
I think that string lookup would be the most convenient. It would actually allow for it to be used with other python objects like pandas dataframes etc. Using keywords outside of function arguments doesn't seem to mix well with the python ecosystem. |
I like the string lookup idea. I pretty much never use the so would |
I guess it would just be equal to |
Remove |
The current proposals would still work though? it would just be a lookup for a string key. |
And in particular, |
Awesome, looks like there's enough buy-in so I'll start up a PR for this. |
I have the next code:
Expected:
Actually:
At the same time, Clojure's name
returns
"under_scored"`. Please, fix it.The text was updated successfully, but these errors were encountered: