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

Extending getter/setter syntax to [] #10

Open
heartsentwined opened this issue Apr 22, 2013 · 2 comments
Open

Extending getter/setter syntax to [] #10

heartsentwined opened this issue Apr 22, 2013 · 2 comments

Comments

@heartsentwined
Copy link

Proposed syntax:

foo['bar'] to be the equivalent of foo.bar (i.e. ember's getter/setter); foo*['bar'] would be its native equivalent.

Main use case is for dynamic property access. In vanilla js, when we access a variable property of an object, we write foo[bar], because foo.bar would compile to a literal key bar.

Extending the . syntax to [] could generate:

get$(foo, bar)
set$(foo, bar, 'baz')

from both of the following:

foo.bar
foo.bar = 'baz'
foo.get bar
foo.set bar, 'baz'

At present, only the latter is available for dynamic ember getter/setter access.

@ghempton
Copy link
Owner

This seems good. I will think about it more. Thanks!

@kristianmandrup
Copy link

👍 awesome idea

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

No branches or pull requests

3 participants