-
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
String Interpolation in keys of object literals #1731
Comments
Related: #786 |
closing as duplicate of #786 |
What was the reasoning behind the close? To me it seems like a bug, or at least an inconsistency. |
Maybe you should ask @jashkenas in #786. I remember that we decided to remove dynamic keys, but not why. And it wasn't explained/linked in the commit. |
I asked ages ago in #786 but he hasn't replied. I guess this is "just one of those things". |
Sorry for being tardy -- if I remember correctly, it was because some of our other language features depend on having the key known at compile time. For example, method overrides and super calls in executable class bodies. We want to know the name of the key so that a proper super call can be constructed. Also, it makes it so that you have to closure-wrap objects when used as expressions (the common case) whenever you have a dynamic key. Finally, there's already a good syntax for dynamic keys in JavaScript which is explicit about what you're doing: There's something nice about having the |
Thanks for the response, it's well reasoned, and I can support it. |
Thank you for clarifying this for us @jashkenas. I've made a note of this in the original ticket. |
FYI:
True, but orthogonal to this issue.
Wrong. You never need to IIFE-wrap them since objects are always expressions. |
@satyr: the dynakey proposal isn't looking good. Good riddance, I didn't like it at all. |
I know this has been closed and I'm sure no one would like to comment on or answer this but I am going to point something out that relates to coffeescript and store.js: It would be super helpful to be able to do string interpolation for store.js ... do_something = for num in [5...1] store.js README: https://github.com/marcuswestin/store.js/#readme |
@wackfordjf3 Not sure I read correctly your code, but you should re-read the linked ticket |
The following code:
Gives the following error:
I would expect to be able to interpolate string keys of object literals.
The text was updated successfully, but these errors were encountered: