Set constructor arguments

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Feb 15 00:56:53 PST 2012


As long as we don't end up with ambiguous constructor as Array could be (
Array(1) VS Array([1]) ) ... so what if the iterable *is* the value I would
like to add() automatically ?

If it's about auto magic population with auto magic filtering and ordering
of potential duplicated values ( and already too much magic, imo ) I would
keep Set.length 0 accepting 0 to N arguments rather than a single one so
yes, spread through iterable would be ideal.

On the other hand, Map and WeakMap have different relation, based on pairs,
and different kind of pairs ( object only or anything )

What if we leave these constructors in peace and let outer wrappers
eventually decide what kind of sorcery should be applied during
initialization ? :-)

br

On Wed, Feb 15, 2012 at 3:20 AM, Mark S. Miller <erights at google.com> wrote:

> On Tue, Feb 14, 2012 at 12:23 PM, Andrea Giammarchi <
> andrea.giammarchi at 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 <dean at deanlandolt.com>wrote:
>>
>>>
>>>
>>> On Tue, Feb 14, 2012 at 3:07 PM, Andrea Giammarchi <
>>> andrea.giammarchi at 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 <petermichaux at gmail.com
>>>> > wrote:
>>>>
>>>>> On Tue, Feb 14, 2012 at 12:09 AM, Andrea Giammarchi
>>>>> <andrea.giammarchi at 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 at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
>
> --
>     Cheers,
>     --MarkM
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120215/43ef0f37/attachment.html>


More information about the es-discuss mailing list