Re: [heycam/webidl] Why can't an inherited dictionary override something as required? (#321)

The conceptual model is that a dictionary has a bunch of slots named whatever they're named.  If you look at the es-to-dictionary algorithm, you basically just invoke your ancestor dictionary's version to fill its slots, then fill your own.

So the syntax, if it were allowed and with no other changes to anything, would create two slots named "total"; one in PaymentDetailsBase and one in PaymentDetailsInit.  And they would both be initialized by calling Get() (twice; once for each slot) on the given object.

So we _could_ allow this, but it would either want different syntax or having the same syntax mean pretty different things depending on non-local state.  And it would require some changes to the way es-to-dictionary conversion works.

Fwiw, this seems like it would address the web payments use case:

    dictionary PaymentDetailsBase {
      // ... a bunch of other stuff
    };

    dictionary PaymentDetailsMaybeNoTotal : PaymentDetailsBase {
      PaymentItem total;
    };

    dictionary PaymentDetailsInit : PaymentDetailsBase {
      required PaymentItem total;
    };

-- 
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/321#issuecomment-282092133

Received on Friday, 24 February 2017 03:26:46 UTC