- From: Jeffrey Yasskin <jyasskin@chromium.org>
- Date: Mon, 26 Sep 2016 15:03:52 -0700
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: public-script-coord <public-script-coord@w3.org>
On Mon, Sep 26, 2016 at 11:41 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote: > On 9/23/16 9:23 PM, Jeffrey Yasskin wrote: >> >> In >> https://api.csswg.org/bikeshed/?url=https://raw.githubusercontent.com/jyasskin/web-bluetooth-1/masked-data-prefixes/index.bs#device-discovery >> 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 >> >> https://api.csswg.org/bikeshed/?url=https://raw.githubusercontent.com/jyasskin/web-bluetooth-1/masked-data-prefixes/index.bs#ref-for-dom-bluetoothlescanfilterinit-manufacturerdata-5 >> 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. Yep, I'd be happy with an OpenEndedDictionary<BluetoothDataFilterInit> that let me write "for each <var>key</var>/<var>value</var> pair in the dictionary, do: ..." even if I had to check and convert the keys from strings myself. To help with that conversion from strings, it'd be nice to have a pointer from WebIDL to CanonicalNumericIndexString() or the right string->number conversion function if that's not it. > 2) The way you set up properties on canonicalizedFilter.manufacturerData is > using [[Set]] instead of [[DefineOwnProperty]]. You should probably use the > latter. Probably via CreateDataProperty(). Done. > 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. Yes, creating and filling in ES objects from algorithms is difficult. For dictionaries, WebIDL itself says "Let O be a new Object value created as if by the expression ({}).", which doesn't answer the global question either. >> 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 > specced.... Is https://github.com/whatwg/fetch/issues/164 the main issue for that? Jeffrey
Received on Monday, 26 September 2016 22:04:41 UTC