-
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
CS2 Discussion: Features: Getters / Setters #4975
Comments
From @GeoffreyBooth on 2017-05-05 14:21 Getters and setters weren't rejected because we couldn't come up with a workable syntax. They were rejected because it's a language feature that's discouraged. The note in the docs isn't to say "this is how you should do getters and setters in CoffeeScript," it's to say that we discourage them but if you insist you can use them using this verbose syntax. |
From @joeldrapper on 2017-05-06 @GeoffreyBooth Why are they discouraged? |
From @GeoffreyBooth on 2017-05-06 |
From @joeldrapper on 2017-05-06 Thanks @GeoffreyBooth, I’ll take a look at that thread. I think they can be implemented quite easily with class methods if people want to use them. Something like this could work. class BaseObject
@get: (name, fun) ->
Object.defineProperty @::, name,
get: ->
fun()
@set: (name, fun) ->
Object.defineProperty @::, name,
set: (value) ->
fun value Edit: I found a much better way to do this. |
From @CliffS on 2017-05-05 09:50
I have been following the discussions on getters/setters and I totally understand and concur with the reasoning behind not allowing the standard ES6 syntax in CS2.
However, the solution given in the draft manual is, IMO, both unclear and against the general philosophy of CS which is to make things less verbose and easier to use. I am constantly pushing CS as a more concise way of writing JS and having to write the following is simply counter-intuitive.
What about introducing a new syntax? Something on the lines of:
Thoughts?
The text was updated successfully, but these errors were encountered: