Re: [whatwg/webidl] FrozenArray<SomeDictionary> seems like a bad idea. (Issue #1243)

> I think FrozenArray<> has its place. It's the clearly-correct choice for something that cannot ever change after creation. Its name seems very on-point to me.

Where the name misleads perhaps is spec-authors assuming entries become constants, not realizing [create a frozen array](https://webidl.spec.whatwg.org/#dfn-create-frozen-array) is shallow or that there's no way to "freeze" an interface. [crbug 946659](https://bugs.chromium.org/p/chromium/issues/detail?id=946659) doesn't help (as in: WebIDL will freeze everything for me wholesale, which is not the case). Disallowing dictionaries should help (one less nestable type to be confused over). 

The name might be fine if we could clarify a bit where it says _"A [frozen array type](https://webidl.spec.whatwg.org/#dfn-frozen-array-type) is a parameterized type whose values are references to objects that hold a fixed length array of **unmodifiable** values."_

I worry readers might assume the interfaces in e.g. [FrozenArray\<PerformanceServerTiming>](https://w3c.github.io/server-timing/#extension-to-the-performanceresourcetiming-interface) are _"unmodifiable"_ for reasons other than [PerformanceServerTiming](https://w3c.github.io/server-timing/#dom-performanceservertiming)'s own attributes all being `readonly`.

The only thing to dispel this seems to be: _"There is no way to represent a constant frozen array value in IDL."_ — which reads like a WebIDL bug more than any guiding design choice (are non-constant interfaces 👍 👎?)

> shouldn’t `FrozenArray<Promise<SomeDictionary>>` be invalid just as `FrozenArray<SomeDictionary>` should be?

Semantically perhaps, to avoid another loophole. Technically though, the former doesn't seem to violate any design rule AFAICT. In some sense, a Promise is just another interface (used to be), with no requirement to act one way or another.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1243#issuecomment-1351710232

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1243/1351710232@github.com>

Received on Wednesday, 14 December 2022 16:14:40 UTC