Nov 16 meeting notes

Dean Landolt dean at deanlandolt.com
Wed Nov 23 10:29:04 PST 2011


On Wed, Nov 23, 2011 at 1:17 PM, David Herman <dherman at mozilla.com> wrote:

> On Nov 18, 2011, at 2:00 AM, Peter van der Zee wrote:
>
> > On Thu, Nov 17, 2011 at 10:02 PM, Brendan Eich <brendan at mozilla.com>
> wrote:
> >> On Nov 17, 2011, at 11:26 AM, Dean Landolt wrote:
> >>
> >>> Who can resist such a juicy bikeshed...
> >
> > Please keep the general js api consistent.
>
> A foolish consistency...
>
> We also use 'hasOwnProperty' and 'forEach' and 'toLocaleString' in JS. Why
> not use those names? Because it's not the same operation. Neither is it the
> same thing as .length. An array is a sequential data structure, so it uses
> .length. A map and a set is not a sequential data structure, so it should
> not.
>


As a thought experiment imagine someone were to propose
Object.prototype.length -- what exactly would you expect that to mean? How
would this be any different than Map.prototype.length? It'd be just as
nonsensical. I could see `keyLength` being here, and something like
`itemLength` being logical for sets, but these two concepts really are the
same. It could also be said that a set's `itemLength` is the same concept
as an array's.

This merits a new property, delegating the length property where it makes
sense (sequences). IMHO the `count` property captures this intension
nicely. Something like this, perhaps:

Object.prototype.count => total keys
Map.prototype.count => total keys
Set.prototype.count => total items
Array.prototype.length => length
Array.prototype.count => Array.prototype.length (sans holes?)
String.prototype.length => length
String.prototype.count => String.prototype.length
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111123/93d939af/attachment.html>


More information about the es-discuss mailing list