Re: [heycam/webidl] Provide a concise syntax to create IDL dictionaries from prose (#142)

The main problem with writing things as an ES object and assuming implicit application of http://heycam.github.io/webidl/#es-dictionary is that it causes ambiguity in terms of what the actual behavior is, no?  Specifically, consider the case at hand.  The IDL is:

    dictionary PermissionDescriptor {
      required PermissionName name;
    };
    dictionary BluetoothPermissionDescriptor : PermissionDescriptor {
      DOMString deviceId;
      sequence<BluetoothRequestDeviceFilter> filters;
      sequence<BluetoothServiceUUID> optionalServices = [];
    };

Say you were to initialize this dictionary with the ES object literal `{ name: "bluetooth", deviceId: "", filters: []; optionalServices: [] }` using the rules of <http://heycam.github.io/webidl/#es-dictionary>.  What would the resulting IDL dictionary contain in its `filters` member?  The answer is that it depends on whether `Array.prototype[Symbol.iterator]` or `%ArrayIteratorPrototype%.next` was overridden and what it was overridden to do.  There are other cases like this as well.

That is, initialization with an object literal is NOT, in general, the same as direct setting of the dictionary members to the values you want.  This is really unfortunate, but just part of life with ECMAScript.  I assume in your case you want the "direct setting" operation, not the "initialization with an object literal" operation...

We could try to add some syntax for indicating the "direct setting" operation.  I'm torn on whether it should look enough different from ES literals to at least make people stop and realize there is an issue here.  That is, that the thing we set "filters" to is NOT an ES Array but some other type entirely.

---
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/142#issuecomment-237821368

Received on Friday, 5 August 2016 10:51:37 UTC