-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Swap the roles of in
and of
#702
Comments
i do think -1 |
I've had this gripe since I first came across coffeescript, but I thought I was alone and/or nitpicking. +1 for consistency with JS. I even think the proposed syntax reads slightly better. edit: I'd like to note that, since posting this comment almost a year ago, my opinion on this matter has reversed, as can be seen in more recent issues proposing similar changes. |
-1 Most of the dynamic languages I'm used to (ruby, python, groovy, etc) use a for ... in for arrays. I think that js is the exception here, and of and in should stay the same. |
Also for hashes. Ruby:
Python:
Groovy:
It's just that hash (object) in JS is more fundamental data structure than array. |
I think its best to follow javascripts convention where possible. That is certaintly what I am doing with Kaffeine (though this is because it implements progressive enhancement of Javascript syntax, it has to). But I think CS should do the same. |
I've personally never used That, and the consistency with other languages, makes me say -1. |
|
-1 from me. As array items in JS are implemented as normal object properties, the fine distinction between them is always going to be a potential point of confusion, so it would be hard to devise an iteration syntax that is completely unambiguous. However, since the semantic difference is a matter of object properties versus array contents, I think |
Sounds like nearly unanimous consensus, then. To reiterate, the original reason for the different terminology is just regular English: You can say "item in list", and "property of object" -- but "item of list" and "property in object" both sound strange-ish. Closing the ticket. |
I find it pretty confusing that
of
compiles toin
andin
arraywise operations.It'd be easier for beginners if we kept the meaning of
in
from JS and then introducedof
for a cool addition.According to Jeremy it's all about readability, but for me neither reads much better than another:
for key of object
for key, value of object
for item in array
for item, index in array
for key in object
for key, value in object
for item of array
for item, index of array
Do you feel one much more readable than another?
The text was updated successfully, but these errors were encountered: