therealbenwiley at gmail.com
Tue Jul 10 05:26:54 UTC 2018
Oops, meant to send to the rest of the list.
Thanks for the feedback Isiah.
2. Could you elaborate? I believe that's what this is, though I might be
missing your point.
3. a. As I noted on GitHub I also considered that syntax originally. I'm
torn on it because allowing out-of-order index definitions in an array
little seems a bit wacky, but maybe it's not so bad?
b. Hmm, this sounds interesting but I'm not sure I totally follow. Could
you give a more convenient concrete example of the array pattern type for
the example you're discussing?
Le mar. 10 juill. 2018 00 h 15, Isiah Meadows <isiahmeadows at gmail.com> a
> I like the idea, but there's a few tweaks I think could be made:
> 1. `replace` reads like you're doing a string or subarray replace.
> This proposal sounds more like an `update`.
> 2. If you allow it to carry the semantics of `slice()` + `array[index]
> = value`, engines can implement it a bit quicker.
> 3. IMHO, this belongs as syntax, either in addition or in place of
> this proposal's method. If nothing else, it's for consistency with
> object spread, but it also allows you to spread iterables similarly,
> something like `[...iter, index: value]`. We could also introduce that
> as an array pattern type, so we don't need to use elisions so
> frequently to skip values in array destructuring patterns (think:
> `regexp.exec(string)` results, when you don't care about all the
> groups). There's been times where I've had upwards of 3-4 elisions all
> clustered together, and that gets unreadable in a hurry.
> Isiah Meadows
> me at isiahmeadows.com
> On Mon, Jul 9, 2018 at 11:42 PM, Ben Wiley <therealbenwiley at gmail.com>
> > Hi ECMAScript folks,
> > I'm brand new to this process and I've drafted a proposal (and polyfill)
> > a new Array.prototype.replace method. In the vein of Array concat, String
> > replace and the new Object rest spread, Array replace provides a way to
> > shallow clone an array and replace an element in a single statement.
> > Here's the GitHub repo, which outlines API, motivation, use cases,
> > alternatives, and polyfill usage:
> > https://github.com/benwiley4000/array-replace
> > Array replace shouldn't be considered an across-the-board substitute for
> > Array.prototype.splice (which mutates the array) and wouldn't be ideal
> > performance critical applications handling very large arrays. It is well
> > suited for application logic where immutability is desired - a trend
> > Most of the application areas of object rest spread composition syntax
> > building objects, not destructuring them) are also application areas for
> > Array.prototype.replace, when your object happens to be an array.
> > I'm looking forward to any feedback and I'd also love for a champion to
> > in and help, if you think this is an ok idea.
> > Thanks!
> > Ben
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss