- From: Adam Rice <notifications@github.com>
- Date: Tue, 09 Jul 2019 21:01:34 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 10 July 2019 04:01:56 UTC
I don't want to give up on calling `size` as a plain function. The principle that it is a pure function is important to the mental model of streams. Making it a method gives the implication that it can be stateful. The brand check is necessary for the correct functioning of WebIDL-generated code, at least in Blink. Before it can call a C++ method, it needs to make sure it's calling it on an object of the correct type. The way I'm currently doing it in my in-progress implementation in Blink is this: ```idl [ Exposed=(Window,Worker,Worklet), Constructor(QueuingStrategyInit init) ] interface CountQueuingStrategy { readonly attribute any highWaterMark; // size is an accessor that returns a function. readonly attribute any size; }; ``` This still has slightly odd semantics: ```javascript const size = new CountQueuingStrategy({}).size; console.assert(size() == 1); ``` works as expected, but ```javascript const size = CountQueuingStrategy.prototype.size; ``` throws an exception. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/1005#issuecomment-509898162
Received on Wednesday, 10 July 2019 04:01:56 UTC