W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2016

RE: Using objects for a mapping argument

From: Domenic Denicola <d@domenic.me>
Date: Tue, 27 Sep 2016 14:07:58 +0000
To: Jeffrey Yasskin <jyasskin@google.com>
CC: public-script-coord <public-script-coord@w3.org>
Message-ID: <CY1PR0501MB13690AA97759D2DAD1B8E455DFCC0@CY1PR0501MB1369.namprd05.prod.outlook.com>
From: Jeffrey Yasskin [mailto:jyasskin@google.com] 

> The API I'm suggesting looks like:

Your approach seems good then; we should make it work.

> I dealt with users overriding the builtins using a paragraph at https://webbluetoothcg.github.io/web-bluetooth/#terminology saying that when the spec uses a name like `BluetoothUUID.getService`, that has to be interpreted as referring to its original value, not anything the user has set it to. I figure it's silly to force specifications to use a parallel library that people have to learn separately from the built-in JS library.

I think we should not do this. It's not silly to separate the internals from the author-exposed algorithms. They have very different behavior, e.g. they operate on different types, leading to the confusion we see with sequences vs. arrays. 

> I'm just using the array methods to map a function over a sequence. In at least one place, I forgot and just wrote a_sequence.map(). Have other specs picked a different convenient way to say that?

Arrays aren't sequences, as Boris pointed out, so this just doesn't work; the spec is incoherent as of now.

You should do something like create a new sequence, loop over the old one, and add an element to the new sequence whose value is the result of applying the algorithm to the item from the original sequence.
Received on Tuesday, 27 September 2016 14:08:42 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 27 September 2016 14:08:43 UTC