Support get/set #5

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

1 participant

@satyr
Owner

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
Owner

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

  • p: !->
  • p: ~->
@satyr
Owner

closed by 8f07c80; supported accessor properties by overloading ~

@satyr satyr reopened this May 15, 2012
@satyr
Owner

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
Owner

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 in 0900cd5 May 15, 2012
@josher19 josher19 pushed a commit to josher19/LiveScript that referenced this issue Jun 21, 2012
@gkz gkz merge pull request #5 dbe5d52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment