You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Foo extends BarconstFoo=struct('Foo',Bar,{// property; must be set during initialization'foo': undefined,// property with default value (supplied using deep clone)'foo': 42,// property, with value generated by calling the function'foo': Prop.init((self)=>undefined),// property; with getter/setter'foo': Prop({get: (self)=>,set: (self)=>,}),// property; // property, assigned by calling the provided function// Bound method syntax'foo': (self)=>…// Static bound method/property/etc'@foo': (cls)=>…});
Only hard rule is: @ is for static, no @ is instance.
Provide some trait intoProp or something that contains normalization rules for properties that turn everything into a Property({ init(), get(), set() }). The normalization rule for undefined is to throw (to enforce explicit initialization). The normalization rule for Functions is binding on initialization and hiding from enumerable properties and so on.
By default .init(foo, bar, baz) and .namedInit({ foo, bar, baz }) is provided.
Also provide tuple as a special case of/wrapper around struct. Tuple works like struct but assumes property declarations are in order (cannot use object literal) and implements object destructuring.
Js structs have a number of disadvantages:
We could substitute our own syntax:
Only hard rule is:
@
is for static, no@
is instance.Provide some trait
intoProp
or something that contains normalization rules for properties that turn everything into aProperty({ init(), get(), set() })
. The normalization rule for undefined is to throw (to enforce explicit initialization). The normalization rule for Functions is binding on initialization and hiding from enumerable properties and so on.By default
.init(foo, bar, baz)
and.namedInit({ foo, bar, baz })
is provided.Highly flexible; metaprogrammable; supports reflection.
The text was updated successfully, but these errors were encountered: