Re: [heycam/webidl] Allow dictionary default values to reference type members (#717)

My general take on this is that Web IDL exists to codify some union of "desirable" and "widespread" API design patterns.  The aim is to be flexible enough to allow many things but make certain things easy.

In particular, there is a real cost to adding IDL features.  It involves complexity in the IDL spec and  in the multiple IDL parsers and validators (including critical ones that are already having trouble keeping up with spec changes, like the idlharness parser, but also the ones browsers use).

For the specific original motivating case here, I assume the concern with writing
```
    GPUColorWriteFlags writeMask = 15;
```
is that it's not clear to the spec reader what that 15 means in practice?  I agree that this is a problem, and the "flexible non-built-in-feature" solution IDL offers for it at the moment is to write:
```
    GPUColorWriteFlags writeMask = 15 /* GPUColorWriteBits.ALL */;
```
to clearly communicate where this magic number comes from.  It's a bit more burden on the spec author if the value of `ALL` changes, of course.

If we do want to have this sort of pattern in multiple places, then it may be worth creating dedicated IDL syntax for it.  It's not clear to me whether that bar has been reached.  I do think that adding some sort of syntax like this post-facto once it's clear that there is a real need for it has worked ok for IDL in the past.

So if my understanding of the problem that we're trying to solve here is correct, and if my proposed "solution" is acceptable for the moment, I would prefer to not add a dedicated feature for this until it's clear that we have more than one consumer.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/717#issuecomment-487104489

Received on Friday, 26 April 2019 15:44:29 UTC