Proposal: Concise class property definition
Sean Eagan
seaneagan1 at gmail.com
Fri May 20 10:36:44 PDT 2011
The basic idea is to integrate concise object literal extensions [1]
into classes with trait composition [2]. Here's an initial attempt at
the resulting syntax:
class A extends B {
// instance data property constructor parameters
constructor( notAProperty, .plainProperty, ! .nonConfigurable, ~
.nonEnumerable, .nonWritable := 1) {
m(notAProperty)
},
// non-configurable, non-writable, non-enumerable, prototype method
! m(notAProperty) {this.booleanProperty = !!notAProperty},
// non-configurable, on prototype, non-identifier
! "a a": "a a",
// non-writable, on prototype
b:= function() {return "b"},
// non-enumerable, static, same name as a prototype property
static ~b : "b",
// static accessor property
static !~get c() {
return bar();
},
static !~set c(value) {
baz(value);
}
}
[1] http://wiki.ecmascript.org/doku.php?id=strawman:concise_object_literal_extensions
[2] http://wiki.ecmascript.org/doku.php?id=strawman:classes_with_trait_composition
Cheers,
Sean Eagan
More information about the es-discuss
mailing list