Re: [heycam/webidl] record with arbitrary value types as keys? (#509)

Specific use case:

I have a method that returns a bunch of stats defined with different dictionaries. They're all a snapshot in time, so return-by-value makes perfect sense. One of the stats describe how much time a stream has spent in quality limited scenarios described by an enum:
```
enum RTCQualityLimitationReason {
    "none",
    "cpu",
    "bandwidth",
    "other",
};

dictionary RTCOutboundRTPStreamStats : RTCSentRTPStreamStats {
    ...
    record<RTCQualityLimitationReason, double> qualityLimitationDurations;
}
```

This is not allowed, so I changed it to
`record<DOMString, double> qualityLimitationDurations;`
and added a comment saying the only `DOMString`s used are values of `RTCQualityLimitationReason`. I think this is less elegant.

> The values of dictionary members can be references.

Okay, in that case I could also change it to
`Maplike<RTCQualityLimitationReason, double> qualityLimitationDurations;`
and return a new object every time we create the dictionary. (But doesn't `record<RTCQualityLimitationReason, double>` make more sense, as it is intended to be passed by value?)

-- 
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/509#issuecomment-356681253

Received on Wednesday, 10 January 2018 17:50:30 UTC