set.empty() method

Kevin Smith khs4473 at gmail.com
Wed Feb 15 05:58:18 PST 2012


Not to backtrack the conversation, but I'm not convinced that "delete"
should be used to remove an element.  Noone's going to ask me, "how do I
delete an element from the set?".  They're going to ask me, "how do I
remove an element?".  Also, I'm currently suspicious of any parallels
between deleting a property and removing an element from a set.  The whole
point of Set and Map is to provide a collection abstraction independent of
javascript's object model (so as to end the confusion that arises from
their conflation), correct?

Plus, syntax-ignorant tokenizers (like the highlighter on the proposal
page) are going to make delete look pretty weird : )

khs


On Wed, Feb 15, 2012 at 8:07 AM, Michael A. Smith <michael at smith-li.com>wrote:

> +1 on clear() as it's pithy, understandable, and behaves the same in
> Java and Python.
>
> What real benefit comes from drawing this connection between delete()
> and deleteAll()? I suspect the everyday programmer won't care, and the
> ones who do will look it up.
>
> -Michael A. Smith
>
> On Wed, Feb 15, 2012 at 1:47 AM, Mark S. Miller <erights at google.com>
> wrote:
> > clear() is ok. Also, java.util.Map and java.util.Set use clear() so it
> would
> > also be familiar to many people.
> >
> > Perhaps deleteAll() would be more mnemonic, as its relationship with
> > delete() would be obvious?
> >
> >
> > On Tue, Feb 14, 2012 at 10:39 PM, Adam Shannon <adam at ashannon.us> wrote:
> >>
> >> I'd agree with using clear() and isEmpty() with their respective
> actions.
> >>
> >> On Wed, Feb 15, 2012 at 00:37, Brendan Eich <brendan at mozilla.org>
> wrote:
> >> > Good idea, but I suggest an unambiguous verb instead of an
> >> > adjective-or-verb: clear.
> >> >
> >> > "empty" is often used for the predicate, in naming conventions that
> >> > eschew
> >> > "isEmpty" and "emptyp" patterns.
> >> >
> >> > /be
> >> >
> >> >
> >> > Peter Michaux wrote:
> >> >>
> >> >> If some piece of code needs to empty a set, it would be good to do
> >> >> that in a single call
> >> >>
> >> >>     set.empty();
> >> >>
> >> >> Otherwise we might be left doing the following which could be very
> >> >> inefficient.
> >> >>
> >> >>     set.forEach(function(element) {
> >> >>         set['delete'](element);
> >> >>     });
> >> >>
> >> >> 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
> >>
> >>
> >>
> >> --
> >> Adam Shannon
> >> Developer
> >> University of Northern Iowa
> >> Sophomore -- Computer Science B.S. & Mathematics
> >> http://ashannon.us
> >
> >
> >
> >
> > --
> >     Cheers,
> >     --MarkM
> >
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120215/eec5e87e/attachment.html>


More information about the es-discuss mailing list