As we write more Ecmaspeak specs (Streams, 402, Loader), we find the way that ES does branding a bit onerous and opaque. That is, it picks a privileged internal slot and says "if you have this internal slot, you can pass go."
I propose the following instead:
- In a class definition, when defining the internal slots for a class (e.g. "Properties of Map instances" in ES), we can say a magic sentence: "[[MapData]] is Map's branding internal slot."
- We provide two abstract operations, IsBranded(o, Class) and ThrowOnBrandMismatch(o, Class) that do what they say. Example usage:
Potential variant: use a small badge in the heading of the method/abstract op, like streams does for throw/nothrow, like brandcheck(Map).
Does this sound interesting? If so I could work on a PR, because streams is getting really sick of defining IsStreamWhatever(x) abstract ops and repeating the boilerplate everywhere. Having ES lead the way would be great.
As we write more Ecmaspeak specs (Streams, 402, Loader), we find the way that ES does branding a bit onerous and opaque. That is, it picks a privileged internal slot and says "if you have this internal slot, you can pass go."
I propose the following instead:
Potential variant: use a small badge in the heading of the method/abstract op, like streams does for throw/nothrow, like
brandcheck(Map).Does this sound interesting? If so I could work on a PR, because streams is getting really sick of defining IsStreamWhatever(x) abstract ops and repeating the boilerplate everywhere. Having ES lead the way would be great.