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

Why not supporting static gets and sets? #4748

Closed
noAlvaro opened this issue Oct 15, 2017 · 3 comments
Closed

Why not supporting static gets and sets? #4748

noAlvaro opened this issue Oct 15, 2017 · 3 comments

Comments

@noAlvaro
Copy link

noAlvaro commented Oct 15, 2017

This Coffeescript 2 "breaking change" drew my attention because of two situations:

  1. Object.defineProperty only work for objects, being impossible to generate some handy static accessors.
  2. By assuming "slightly more verbose" as best, Coffeescript somewhat deviates from its prior principles.

- Doesn't it?

@GeoffreyBooth
Copy link
Collaborator

No. 1 is wrong: #4746

As for No. 2, our aim is to reveal the best of JavaScript, not support every aspect of it. The code example is only for completeness, to demonstrate that it is still possible to create getters and setters, though we discourage them in general as an antipattern.

@noAlvaro
Copy link
Author

noAlvaro commented Nov 13, 2017

Hey, thanks for correcting. I just found that you put plenty of thought on this already.

With my assumed limitation to argue against the decision, the only issue I do have when trying to avoid this pattern is when getting advanced visual effects to work with animation libraries (like in Framer and others). These libraries usually need to iterate on numeric properties, so getters and setters really come handy when building components... and I couldn't see how to use standard methods instead.

Thanks for explaining!

@GeoffreyBooth
Copy link
Collaborator

Thanks. If you look in the changelog for the 2.0.0 betas, you’ll see we also walled off calling freestanding functions named get or set so that it’s possible for us to revisit this later, without it being a breaking change. Basically, if there are too many interoperability issues with forcing people to either avoid getters and setters or to use the verbose syntax, we can “enable” the shorthand syntax without breaking any existing CS2 code.

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

2 participants