This repository has been archived by the owner on Feb 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
CS2 Discussion: Features: Getters / Setters #82
Comments
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. |
@GeoffreyBooth Why are they discouraged? |
See #17 |
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. |
coffeescriptbot
changed the title
Getters / Setters
CS2 Discussion: Features: Getters / Setters
Feb 19, 2018
Migrated to jashkenas/coffeescript#4975 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: