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

Support get/set #5

Closed
satyr opened this issue Nov 9, 2010 · 4 comments
Closed

Support get/set #5

satyr opened this issue Nov 9, 2010 · 4 comments

Comments

@satyr
Copy link
Owner

satyr commented Nov 9, 2010

With syntax like:

obj = {
  prop: function -> 42
  prop: function (item) -> alert item
}

var obj;
obj = {
  get prop(){
    return 42;
  },
  set prop(item){
    return alert(item);
  }
};
@satyr
Copy link
Owner Author

satyr commented Jan 13, 2011

Still undecided on the syntax. Maybe with a unary that's pointless now:

  • p: !->
  • p: ~->

@satyr
Copy link
Owner Author

satyr commented Jan 13, 2011

closed by 8f07c80; supported accessor properties by overloading ~

@satyr satyr reopened this May 15, 2012
@satyr
Copy link
Owner Author

satyr commented May 15, 2012

Time to improve.

  • Use Object.defineProperty when importing.
  • Make it DRYer.
o <<< p:~
  ->     # get
  (x) -> # set

Object.defineProperty(o, 'p', {
  get: function(){},
  set: function(x){},
  configurable: true,
  enumerable: true
});

@satyr
Copy link
Owner Author

satyr commented May 15, 2012

Preferring that notation, this will be an incompatible change for the literal case. The old way:

o =
  p:~ ->     # get
  p:~ (x) -> # set

will be invalid as duplicate property.

@satyr satyr closed this as completed in 0900cd5 May 15, 2012
josher19 pushed a commit to josher19/LiveScript that referenced this issue Jun 21, 2012
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

1 participant