-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Milestone
Description
const Foldable = new Protocol({
name: 'Foldable',
extends: [ .. ],
requires: {
foldr: Symbol('Foldable.foldr'),
},
staticRequires: { .. },
provides: {
Object.getOwnPropertyDescriptors({
toArray() { .. 1},
get length() { .. },
contains(eq, e) { .. },
}),
staticProvides: { ... },
});- Why would authors need to construct
Symbol('Foldable.foldr')themselves? That seems antithetical to one of the core tenets of this feature (that you use symbols under the hood without defining them yourself) and introduces a disparity between the constructor and the declarative syntax (which A way to require different symbol fields thanProtocolName.*#48 would plug). providesaccepting descriptors also introduces a disparity between the constructor and the declarative syntax, and requires boilerplate in the vast majority of cases. It also seems like a footgun: since the most natural syntax is to just include the object literal, I can easily see authors doing that. We could define that the feature copies descriptors from these objects, which gives you the best of both worlds (simple things are easy, complex things are possible) but is specifying descriptors actually desirable? E.g. class members are non-enumerable by default. Would protocol-provided members need to be specified as explicitlyenumerable: falseto behave the same way?- Why is there a
namefield? What is it used for? Isn'tconst Foldableenough since everything is by reference?