Re: Using objects for a mapping argument

On 9/23/16 9:23 PM, Jeffrey Yasskin wrote:
> In
> defines some arguments to a function in which I want users to express
> a map from integers or strings to a dictionary. One of the arguments
> will look like {0x004C: {dataPrefix: [0x02, 0x15]}}, while the other
> could be {0xFEAA: {dataPrefix: [0x10]}, "battery_service": {}}.

For your case, where each value has the same "shape" (in that they are 
all converted to the same dictionary), this is basically similar to the 
OpenEndedDictionary proposal, right?

> This is processed at
> using explicit calls to `.[[OwnPropertyKeys]]()` and some other
> ECMAScript operations.

Right, so compared to the other uses of OpenEndedDictionary this has the 
following additional wrinkles:

1)  Some constraints on the "keys" of the dictionary.  This is fine; 
other consumers want this too; it's simple enough to express in prose.

2)  The way you set up properties on 
canonicalizedFilter.manufacturerData is using [[Set]] instead of 
[[DefineOwnProperty]].  You should probably use the latter.

3)  Since you're going around creating ES objects, there's the usual 
question of whether you want to use the global of the callee function or 
the global of the "this" value to do that.

> Does this make sense, or should I have my users express these
> arguments in some other way?

In general, this makes sense.  We should really get OpenEndedDictionary 


Received on Monday, 26 September 2016 18:41:34 UTC