Proposal: Concise class property definition
# Allen Wirfs-Brock (14 years ago)
On May 20, 2011, at 10:36 AM, Sean Eagan wrote:
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:
I've update [1] and integrated with some related proposals to make the integrated proposal tree starting at strawman:basic_object_literal_extensions
We should use that as the starting point for the class integration.
# Sean Eagan (14 years ago)
I sent out a separate proposal for just the concise instance initialisation part which is relevant to any constructor, not just classes. I'll work on the classes integration separately.
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] strawman:concise_object_literal_extensions [2] strawman:classes_with_trait_composition