On Tue, Oct 7, 2014 at 12:27 PM, Dmitry Soshnikov < [email protected]> wrote:
> On Tue, Oct 7, 2014 at 12:25 PM, Dmitry Soshnikov < > [email protected]> wrote: > > On Tue, Oct 7, 2014 at 12:22 PM, Rick Waldron <[email protected]> >> wrote: >> >> >>> >>> On Tue, Oct 7, 2014 at 3:01 PM, Dmitry Soshnikov < >>> [email protected]> wrote: >>> >>>> On Tue, Oct 7, 2014 at 11:59 AM, Dmitry Soshnikov < >>>> [email protected]> wrote: >>>> >>>>> On Tue, Oct 7, 2014 at 11:56 AM, Claude Pache <[email protected]> >>>>> wrote: >>>>> >>>>> >>>>>> >>>>>> >>>>>> > Le 7 oct. 2014 à 20:36, Dmitry Soshnikov < >>>>>> [email protected]> a écrit : >>>>>> > >>>>>> > And other things are better be written: >>>>>> > >>>>>> > ``` >>>>>> > <ArrayKind>.from(iterable).map(mapfn) >>>>>> > ``` >>>>>> > >>>>>> > Am I still missing something? >>>>>> >>>>>> Yes: `UInt32Array.from(['a', 'b', 'c], x => x.codePointAt(0))` >>>>>> >>>>>> >>>>> Still seems the same as `NodeList` "issue": >>>>> >>>>> ``` >>>>> UInt32Array.from(['a', 'b', 'c].map(x => x.codePointAt(0))); >>>>> ``` >>>>> >>>> >>>> And after you have fed the data the `UInt32Array` expects, you can >>>> post-map it as well: >>>> >>>> >>>> ``` >>>> UInt32Array.from(['a', 'b', 'c].map(x => x.codePointAt(0))).map(v => v >>>> * 2); >>>> ``` >>>> >>>> What's is wrong in here? >>>> >>> >>> That example will allocate 2 additional objects; the following version >>> of the same operation will allocate _zero_ additional objects: >>> >>> UInt32Array.from(['a', 'b', 'c], x => x.codePointAt(0) * 2); >>> >>> >> Exactly. And this is what I mentioned at the beginning: the performance >> reasons shouldn't (never) overweight in "good API design" topics. >> >> > Since the next question will be: where is filter? It allows not allocating > stuff at all. However, we won't mention whether it's an anti-pattern or > not, since it goes without saying. > > I mean, yeah, we can accept and live with this -- aka, yeah why not, it's convenient in place to pre-map, and good for cases when an iterable doesn't have the `map`, and it's good for performance. But all the things from above stands: it's confusing since doesn't explain whether it's pre- or post- map, and takes too much at implementation. Otherwise, I think it can be there, as long as it was approved already. Worth though considering this in the future API designs: the performance shouldn't drive the API. Dmitry
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

