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

Get/Set syntax #64

Closed
zmthy opened this issue Jan 8, 2010 · 3 comments
Closed

Get/Set syntax #64

zmthy opened this issue Jan 8, 2010 · 3 comments

Comments

@zmthy
Copy link
Collaborator

zmthy commented Jan 8, 2010

Would a bit of syntax for getters and setters be a good idea? Its use would obviously make it incompatible with implementations of JS that don't support them, but that's the case with using them in the JS anyway. It would just be a little nicer than throwing defineGetter all over the place.

@jashkenas
Copy link
Owner

I don't think that non-standard extensions belong in mainline CoffeeScript, but you could certainly start a "rhino" branch that provides convenient syntax for goodies like this. The issue with putting it on the mainline is that it complicates the grammar, and reserves syntax that we might later want to dedicate to other purposes, in order to support a feature that many people won't be able to use.

Closing the ticket.

@StanAngeloff
Copy link
Contributor

Here is my getters_setters branch. Some examples from the test file:

obj: {
  set value: (val) ->
    @val: '' + val + val
  get value: ( -> # Anonymous functions are converted to proper getters
    @val + @val
  )
}

class Obj
  constructor: ->
    @val: 0

  increment: ->
    @val: + 1

  set value: (val) ->
    @val: val

  get value: ->
    @val

@aurium
Copy link
Contributor

aurium commented May 14, 2016

Six years after, with all ES6 discussion, @StanAngeloff's proposal looks more compatible to the reality and strongly necessary.

This issue was closed.
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

4 participants