+1 on ... (spread) exhausting an iterator to expand the iterated values into positional parameters or initialisers.

/be

Mark S. Miller wrote:
On Tue, Feb 14, 2012 at 12:23 PM, Andrea Giammarchi <andrea.giammar...@gmail.com <mailto:andrea.giammar...@gmail.com>> wrote:

    nope, Set does not even accept arguments as it is now ... does it ?


Not now. But this thread suggests changing it to do so. I think I agree but don't yet have a strong opinion about whether Set should have a single iteratable parameter or a rest parameter of the individual elements.

Relevant question: What should spread (... in a call expression) do when its operand is an iterator or iteratable? Currently spread simple treats its operand as array-like, in which case I think perhaps Set should stick with a single parameter. If we can generalize spread to enumerate the values obtained from an iterator, then I think perhaps Set should go with the spread parameter.

Whatever we decide for Set should also guide what we do for Map and WeakMap of course.




    On Tue, Feb 14, 2012 at 9:20 PM, Dean Landolt
    <d...@deanlandolt.com <mailto:d...@deanlandolt.com>> wrote:



        On Tue, Feb 14, 2012 at 3:07 PM, Andrea Giammarchi
        <andrea.giammar...@gmail.com
        <mailto:andrea.giammar...@gmail.com>> wrote:

            if you accept a single argument, of course, but what if
            you Set(..[1, 2, 1]) then ?


        `Set(1, 2, 1)` then? Are you suggesting this should throw? So
        you'd need to dedupe your arguments before you construct a set
        with them? Isn't that a primary use case of sets?


            magic add through Set constructor does not sound good to me


            On Tue, Feb 14, 2012 at 8:27 PM, Peter Michaux
            <petermich...@gmail.com <mailto:petermich...@gmail.com>>
            wrote:

                On Tue, Feb 14, 2012 at 12:09 AM, Andrea Giammarchi
                <andrea.giammar...@gmail.com
                <mailto:andrea.giammar...@gmail.com>> wrote:
                > thinking about the add behavior, where no duplicated
                values will be added,
                > this argument may cause some logic headache anyway
                >
                > Set([1, 2, 1]) what should happen ?

                I think that should be a set with one element. The
                element is an array
                of length three.

                Peter



            _______________________________________________
            es-discuss mailing list
            es-discuss@mozilla.org <mailto:es-discuss@mozilla.org>
            https://mail.mozilla.org/listinfo/es-discuss




    _______________________________________________
    es-discuss mailing list
    es-discuss@mozilla.org <mailto:es-discuss@mozilla.org>
    https://mail.mozilla.org/listinfo/es-discuss




--
    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to