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

unquote-splice interacts with HySymbol weirdly #1509

Closed
vodik opened this issue Feb 15, 2018 · 5 comments
Closed

unquote-splice interacts with HySymbol weirdly #1509

vodik opened this issue Feb 15, 2018 · 5 comments

Comments

@vodik
Copy link
Contributor

vodik commented Feb 15, 2018

I think this can be addressed in #1504, if I also break HySymbol so it doesn't inherit from str, like I did with HyKeyword, because otherwise this happens:

=> `(~@'range)
HyExpression([
  'r',
  'a',
  'n',
  'g',
  'e'])

HySymbol shouldn't be iterable.

@Kodiologist
Copy link
Member

Why not? That seems like a fine behavior to me.

@vodik
Copy link
Contributor Author

vodik commented Feb 15, 2018

Because its an implicit type coercion that makes no sense imho:

=> (list 'foo)
['f', 'o', 'o']

A symbol was turned into a string that was iterated on. I mean, if this behaviour showed up, how much more likely is to have been a bug than the intended behaviour?

But imho I'm really not a fan of treating symbols as strings.

@Kodiologist
Copy link
Member

They seem very string-like to me, is all I can say, I guess. Certainly I wouldn't have expected (list 'foo) to do something else.

@gilch gilch changed the title unquote-slice interacts with HySymbol weirdly unquote-splice interacts with HySymbol weirdly Feb 15, 2018
@vodik
Copy link
Contributor Author

vodik commented Feb 15, 2018

Honestly, I would have expected a TypeError or ValueError. I think its more the type cohesion to string that's happening is what's bothering me (e.g. (= (string? 'foo) True) also rubs me the wrong way).

I think I can understand why it was done intentionally, when getattr and co take strings, and python objects are really just tables, but they're not really the same thing. Attributes are a subset of valid keys. so I have no expectation for them to be interchangeable. I guess Hy is also not limited to Python's rules for identifiers.

I mean, I can live with it.

@Kodiologist
Copy link
Member

Things have changed since this issue such that (= 'foo "foo") is no longer true, but it's still true that (list 'foo) produces ["f" "o" "o"], and I still think that's correct. If there is substantial disagreement, we can reconsider this.

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

No branches or pull requests

3 participants