Re: Destructuring for Array-like objects

2019-03-22 Thread guest271314
="testb"; const {0: c, 1: d} = {0: a, 1: b, length: 2} > results in a const 'c' and const 'd' created with the vlaues of a and b. > > shouldn't it have created a variable '0' and '1' ? &g

Re: Destructuring for Array-like objects

2019-03-22 Thread J Decker
results in a const 'c' and const 'd' created with the vlaues of a and b. shouldn't it have created a variable '0' and '1' ? > > On Wed, Mar 20, 2019 at 12:59 AM Sultan wrote: > >>

Re: Destructuring for Array-like objects

2019-03-22 Thread guest271314
If gather the expected result correctly object destructuring can be used const {0: a, 1: b} = {0: a, 1: b, length: 2} On Wed, Mar 20, 2019 at 12:59 AM Sultan wrote: > Afford array destructuring to Array-like objects. > > const [a, b] = {0: a, 1: b,

Re: Destructuring for Array-like objects

2019-03-19 Thread Jordan Harband
, > length: 2, > *[Symbol.iterator]() { > let i = 0; > while (i < this.length) { > yield this[i] > i++ > } > }, > }; > > > > On Mar 20 2019, at 11:59 am, Sultan wrote: > > Affor

Re: Destructuring for Array-like objects

2019-03-19 Thread Frederick Stark
wrote: > Afford array destructuring to Array-like objects. > > const [a, b] = {0: a, 1: b, length: 2} > > ___ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >

Re: Destructuring for Array-like objects

2019-03-19 Thread Ranando King
Why is that any different or better than const [a, b] = [a, b] ? On Tue, Mar 19, 2019 at 7:59 PM Sultan wrote: > Afford array destructuring to Array-like objects. > > const [a, b] = {0: a, 1: b, length: 2} > > > ___ > es-disc

Destructuring for Array-like objects

2019-03-19 Thread Sultan
Afford array destructuring to Array-like objects. const [a, b] = {0: a, 1: b, length: 2} ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Intercepting sets on array-like objects

2017-06-09 Thread Tab Atkins Jr.
On Fri, Jun 9, 2017 at 2:07 PM, Domenic Denicola wrote: > I'm not really sure how you're expecting to get an answer "according to > TC39." I was told by Anne in to "go back to TC39 I suppose and say you really want to do typed a

Re: Intercepting sets on array-like objects

2017-06-09 Thread Domenic Denicola
x27;m sure there will be many other opinions from other TC39 members. From: "Tab Atkins Jr." Sent: Jun 9, 2017 5:02 PM To: Adam Klein Cc: es-discuss Subject: Re: Intercepting sets on array-like objects On Fri, Jun 9, 2017 at 1:57 PM, Adam Klein wrote: >

Re: Intercepting sets on array-like objects

2017-06-09 Thread Tab Atkins Jr.
On Fri, Jun 9, 2017 at 1:57 PM, Adam Klein wrote: > On Thu, Jun 8, 2017 at 11:32 AM, Tab Atkins Jr. > wrote: >> Note that if we don't get some variant of this functionality, these >> APIs will instead do one of: >> >> * just using Proxies (already defined in WebIDL) > > > When you say "Proxies" h

Re: Intercepting sets on array-like objects

2017-06-09 Thread Adam Klein
On Thu, Jun 8, 2017 at 11:32 AM, Tab Atkins Jr. wrote: > Heya! As part of designing the CSS Typed OM > , we've ended up with at > three (so far) places where we want an interface that represents a > list of values: > > * CSSUnparsedValue >

Re: Intercepting sets on array-like objects

2017-06-08 Thread Allen Wirfs-Brock
> On Jun 8, 2017, at 11:32 AM, Tab Atkins Jr. wrote: > > Naively, this requires a Proxy, so we can intercept uses of the [] > syntax. However, we don't need all the rest of the Proxy > functionality, just this one intercept - a setter function, just for > `obj[foo]` rather than `obj.foo`. Furt

Re: Intercepting sets on array-like objects

2017-06-08 Thread Mark S. Miller
Interesting. At https://github.com/tvcutsem/es-lab/issues/21 Tom and I have been discussing a way to make Proxies cheaper, and Proxies that only override a few traps and let the rest default, much cheaper. On Thu, Jun 8, 2017 at 11:32 AM, Tab Atkins Jr. wrote: > Heya! As part of designing the

Intercepting sets on array-like objects

2017-06-08 Thread Tab Atkins Jr.
Heya! As part of designing the CSS Typed OM , we've ended up with at three (so far) places where we want an interface that represents a list of values: * CSSUnparsedValue , representi

Re: array like objects

2009-12-16 Thread P T Withington
On 2009-12-15, at 23:28, Brendan Eich wrote: > Something more like Self, in other words. I still wonder if we can't recover > that lost form, enable prototype-based composition as Tucker wanted, and > banish host objects to the ninth circle of hell, in a future edition. We can dream! :) __

Re: array like objects

2009-12-15 Thread Brendan Eich
On Dec 15, 2009, at 12:32 PM, David-Sarah Hopwood wrote: Exactly: [[Class]] is associated with each instance and so are the other internal methods/properties, but that doesn't imply that other properties are "defined based on" [[Class]]. The internal methods specified for built-in objects

Re: array like objects

2009-12-15 Thread David-Sarah Hopwood
Brendan Eich wrote: > On Dec 15, 2009, at 11:18 AM, David-Sarah Hopwood wrote: >> Brendan Eich wrote: >>> In ES specs and real implementations, internal methods and various >>> corresponding implementation hooks are called based on [[Class]] of the >>> directly referenced object, in contrast. [...]

Re: array like objects

2009-12-15 Thread Brendan Eich
On Dec 15, 2009, at 11:18 AM, David-Sarah Hopwood wrote: Brendan Eich wrote: In ES specs and real implementations, internal methods and various corresponding implementation hooks are called based on [[Class]] of the directly referenced object, in contrast. In ES specs, there's no indicatio

Re: array like objects

2009-12-15 Thread P T Withington
On 2009-12-15, at 13:59, Mike Samuel wrote: > 2009/12/15 P T Withington : >> On 2009-12-08, at 13:10, Mike Samuel wrote: >> >>> All true. And yet it is not uncommon. See the bottom of this email >>> for a quick survey of a number of libraries' uses of the array-like >>> concept. >> >> FWIW, He

Re: array like objects

2009-12-15 Thread David-Sarah Hopwood
Brendan Eich wrote: > In ES specs and real implementations, internal methods and various > corresponding implementation hooks are called based on [[Class]] of the > directly referenced object, in contrast. In ES specs, there's no indication that [[Class]] can or should be used for internal method

Re: array like objects

2009-12-15 Thread Mike Samuel
2009/12/15 P T Withington : > On 2009-12-08, at 13:10, Mike Samuel wrote: > >> All true.  And yet it is not uncommon.  See the bottom of this email >> for a quick survey of a number of libraries' uses of the array-like >> concept. > > FWIW, Here is the (separately/simultaneously invented) definitio

Re: array like objects

2009-12-15 Thread Brendan Eich
On Dec 15, 2009, at 8:46 AM, Jorge Chamorro wrote: It's the same functionality provided by Object.create(), but for [] instead of {}. Ah, that helps -- thanks. This is not exactly what Tucker showed, though. Tucker is looking for a way to compose custom [[Put]] with prototype-based del

Re: array like objects

2009-12-15 Thread Jorge Chamorro
On 15/12/2009, at 16:21, Brendan Eich wrote: > On Dec 15, 2009, at 5:05 AM, Jorge Chamorro wrote: >> On 15/12/2009, at 13:51, P T Withington wrote: >>> (...) >>> I once had the vain hope that I could say: >>> >>> function MyArray () {} >>> MyArray.prototype = []; >>> >>> to create my own subclass

Re: array like objects

2009-12-15 Thread Brendan Eich
On Dec 15, 2009, at 5:05 AM, Jorge Chamorro wrote: On 15/12/2009, at 13:51, P T Withington wrote: (...) I once had the vain hope that I could say: function MyArray () {} MyArray.prototype = []; to create my own subclasses of Array. That might have lessened the need for isArrayLike. For t

Re: array like objects

2009-12-15 Thread Brendan Eich
On Dec 15, 2009, at 4:51 AM, P T Withington wrote: On 2009-12-08, at 13:10, Mike Samuel wrote: All true. And yet it is not uncommon. See the bottom of this email for a quick survey of a number of libraries' uses of the array-like concept. FWIW, Here is the (separately/simultaneously inven

Re: array like objects

2009-12-15 Thread Jorge Chamorro
On 15/12/2009, at 13:51, P T Withington wrote: > (...) > I once had the vain hope that I could say: > > function MyArray () {} > MyArray.prototype = []; > > to create my own subclasses of Array. That might have lessened the need for > isArrayLike. For that, we'd need an Array.create(). It mi

Re: array like objects

2009-12-15 Thread P T Withington
On 2009-12-08, at 13:10, Mike Samuel wrote: > All true. And yet it is not uncommon. See the bottom of this email > for a quick survey of a number of libraries' uses of the array-like > concept. FWIW, Here is the (separately/simultaneously invented) definition from OpenLaszlo: function isArr

Re: array like objects

2009-12-14 Thread Garrett Smith
On Mon, Dec 14, 2009 at 11:29 AM, Mike Samuel wrote: > 2009/12/14 Garrett Smith : >> On Mon, Dec 14, 2009 at 9:34 AM, Mike Samuel wrote: >>> 2009/12/13 Garrett Smith : On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel wrote: > 2009/12/12 Garrett Smith : >> On Sat, Dec 12, 2009 at 4:04 P

Re: array like objects

2009-12-14 Thread Breton Slivka
On Tue, Dec 15, 2009 at 10:34 AM, Mike Samuel wrote: > 2009/12/14 Breton Slivka : >> On Tue, Dec 15, 2009 at 6:29 AM, Mike Samuel wrote: >> >>> (3) If (!1), should future EcmaScript drafts define iteration order >>> for arrays as index order and possibly recommend to array like host >>> objects t

Re: array like objects

2009-12-14 Thread Mike Samuel
2009/12/14 Breton Slivka : > On Tue, Dec 15, 2009 at 6:29 AM, Mike Samuel wrote: > >> (3) If (!1), should future EcmaScript drafts define iteration order >> for arrays as index order and possibly recommend to array like host >> objects that the define iteration order similarly. > > > I would sugge

Re: array like objects

2009-12-14 Thread Breton Slivka
On Tue, Dec 15, 2009 at 6:29 AM, Mike Samuel wrote: > (3) If (!1), should future EcmaScript drafts define iteration order > for arrays as index order and possibly recommend to array like host > objects that the define iteration order similarly. I would suggest that this change would be mostly u

Re: array like objects

2009-12-14 Thread Mike Samuel
2009/12/14 Garrett Smith : > On Mon, Dec 14, 2009 at 9:34 AM, Mike Samuel wrote: >> 2009/12/13 Garrett Smith : >>> On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel wrote: 2009/12/12 Garrett Smith : > On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller > wrote: >> On Sat, Dec 12, 2009

Re: array like objects

2009-12-14 Thread Garrett Smith
On Mon, Dec 14, 2009 at 9:34 AM, Mike Samuel wrote: > 2009/12/13 Garrett Smith : >> On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel wrote: >>> 2009/12/12 Garrett Smith : On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller wrote: > On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith > wrote: >

Re: array like objects

2009-12-14 Thread Mike Samuel
2009/12/13 Garrett Smith : > On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel wrote: >> 2009/12/12 Garrett Smith : >>> On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller wrote: On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith wrote: > > On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller

Re: array like objects

2009-12-13 Thread Garrett Smith
On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel wrote: > 2009/12/12 Garrett Smith : >> On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller wrote: >>> On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith >>> wrote: On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller wrote: > Are we really th

Re: array like objects

2009-12-13 Thread Mike Samuel
2009/12/12 Garrett Smith : > On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller wrote: >> On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith >> wrote: >>> >>> On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller >>> wrote: >>> > Are we really this stuck? Can anyone think of a reliable, portable, and >>> > f

Re: array like objects [correction]

2009-12-13 Thread Mike Samuel
2009/12/11 Mark S. Miller : > On Fri, Dec 11, 2009 at 4:33 PM, David-Sarah Hopwood > wrote: >> >> David-Sarah Hopwood wrote: >> > Mark S. Miller wrote: >> >> function isArrayLike(obj) { >> >>   var len; >> >>   return !!(obj && >> >>             typeof obj === 'object' && >> >>             'length

Re: array like objects

2009-12-13 Thread Brendan Eich
On Dec 12, 2009, at 12:36 PM, Mark S. Miller wrote: On Sat, Dec 12, 2009 at 12:29 PM, Garrett Smith > wrote: Object.prototype.propertyIsEnumerable does not consider properties in the prototype chain. In effect, propertyIsEnumerable is a test to see if an object has *own* property that is also en

Re: array like objects

2009-12-12 Thread Garrett Smith
On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller wrote: > On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith > wrote: >> >> On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller >> wrote: >> > Are we really this stuck? Can anyone think of a reliable, portable, and >> > fast >> > ES3R test that tests whethe

Re: array like objects

2009-12-12 Thread Mike Samuel
2009/12/12 Garrett Smith : > On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: >> Mark S. Miller wrote: >> >> If we're looking for a convention that is >> * does not admit any legacy ES3R non-array non-host objects (to prevent >> false positives) > > No native ES objects? > >> * does easily all

Re: array like objects

2009-12-12 Thread Mike Samuel
2009/12/12 Brendan Eich : > On Dec 12, 2009, at 10:36 AM, Mike Samuel wrote: > >> 2009/12/12 Mike Wilson : >>> >>> David-Sarah Hopwood wrote: Mark S. Miller wrote: > > function isArrayLike(obj) { >  var len; >  return !!(obj && >            typeof obj === 'object' && >

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith wrote: > On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller > wrote: > > Are we really this stuck? Can anyone think of a reliable, portable, and > fast > > ES3R test that tests whether a property is enumerable, whether it is > > inherited or not? > > >

Re: array like objects

2009-12-12 Thread Garrett Smith
On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller wrote: > On Sat, Dec 12, 2009 at 12:29 PM, Garrett Smith > wrote: >> Object.prototype.propertyIsEnumerable does not consider properties in >> the prototype chain. In effect, propertyIsEnumerable is a test to see >> if an object has *own* property th

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 12:29 PM, Garrett Smith wrote: > Object.prototype.propertyIsEnumerable does not consider properties in > the prototype chain. In effect, propertyIsEnumerable is a test to see > if an object has *own* property that is also enumerable. At the end of < http://wiki.ecmascript.

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 12:29 PM, Garrett Smith wrote: > Object.prototype.propertyIsEnumerable does not consider properties in > the prototype chain. In effect, propertyIsEnumerable is a test to see > if an object has *own* property that is also enumerable. > And just when I was thinking I was fi

Re: array like objects

2009-12-12 Thread Garrett Smith
On Sat, Dec 12, 2009 at 12:01 PM, Mark S. Miller wrote: > On Sat, Dec 12, 2009 at 11:21 AM, Garrett Smith > wrote: >> >> On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: >> > Mark S. Miller wrote: >> > >> > If we're looking for a convention that is >> > * does not admit any legacy ES3R non-a

Re: array like objects

2009-12-12 Thread Brendan Eich
On Dec 12, 2009, at 10:36 AM, Mike Samuel wrote: 2009/12/12 Mike Wilson : David-Sarah Hopwood wrote: Mark S. Miller wrote: function isArrayLike(obj) { var len; return !!(obj && typeof obj === 'object' && 'length' in obj && !({}).propertyIsEnumerable.cal

Re: array like objects

2009-12-12 Thread Brendan Eich
On Dec 12, 2009, at 11:36 AM, Mike Wilson wrote: Mark S. Miller wrote: On Sat, Dec 12, 2009 at 10:36 AM, Mike Samuel wrote: On the String defect, we could repair that with && ({}).toString.call(obj) !== '[object String]' Cons: An extra function call in the likely case Strings are arg

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 11:21 AM, Garrett Smith wrote: > On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: > > Mark S. Miller wrote: > > > > If we're looking for a convention that is > > * does not admit any legacy ES3R non-array non-host objects (to prevent > > false positives) > > No native

RE: array like objects

2009-12-12 Thread Mike Wilson
Mark S. Miller wrote: On Sat, Dec 12, 2009 at 10:36 AM, Mike Samuel wrote: On the String defect, we could repair that with && ({}).toString.call(obj) !== '[object String]' Cons: An extra function call in the likely case Strings are arguable array-like Pros: Strings are inconsistently

Re: array like objects

2009-12-12 Thread Garrett Smith
On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: > Mark S. Miller wrote: > > If we're looking for a convention that is > * does not admit any legacy ES3R non-array non-host objects (to prevent > false positives) No native ES objects? > * does easily allow ES5 programmers to define new array-

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 10:36 AM, Mike Samuel wrote: > 2009/12/12 Mike Wilson : > > David-Sarah Hopwood wrote: > >> Mark S. Miller wrote: > >> > function isArrayLike(obj) { > >> > var len; > >> > return !!(obj && > >> > typeof obj === 'object' && > >> > 'length' in obj

RE: array like objects

2009-12-12 Thread Mike Wilson
Mark S. Miller wrote: On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: [...] I'm not sure where it should be put, but maybe there should be an official ES "duck" page with committee approved patterns ;-). Without claiming any "approvals" per se, I have started a "conventions:" namespac

Re: array like objects

2009-12-12 Thread Mike Samuel
2009/12/12 Mike Wilson : > David-Sarah Hopwood wrote: >> Mark S. Miller wrote: >> > function isArrayLike(obj) { >> >   var len; >> >   return !!(obj && >> >             typeof obj === 'object' && >> >             'length' in obj && >> >             !({}).propertyIsEnumerable.call(obj, 'length') &&

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: > [...] I'm not sure where it should be put, but maybe there should be an > official ES "duck" page with committee approved patterns ;-). > Without claiming any "approvals" per se, I have started a "conventions:" namespace

RE: array like objects

2009-12-12 Thread Mike Wilson
David-Sarah Hopwood wrote: > Mark S. Miller wrote: > > function isArrayLike(obj) { > > var len; > > return !!(obj && > > typeof obj === 'object' && > > 'length' in obj && > > !({}).propertyIsEnumerable.call(obj, 'length') && > > (len = obj.length)

Re: array like objects [correction]

2009-12-11 Thread Mark S. Miller
On Fri, Dec 11, 2009 at 4:33 PM, David-Sarah Hopwood < david-sa...@jacaranda.org> wrote: > David-Sarah Hopwood wrote: > > Mark S. Miller wrote: > >> function isArrayLike(obj) { > >> var len; > >> return !!(obj && > >> typeof obj === 'object' && > >> 'length' in obj && >

Re: array like objects [correction]

2009-12-11 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: > Mark S. Miller wrote: >> function isArrayLike(obj) { >> var len; >> return !!(obj && >> typeof obj === 'object' && >> 'length' in obj && >> !({}).propertyIsEnumerable.call(obj, 'length') && >> (len = obj.length) >>> 0

Re: array like objects

2009-12-11 Thread David-Sarah Hopwood
Mark S. Miller wrote: > On Fri, Dec 11, 2009 at 2:27 AM, Mike Wilson wrote: > >> I think Breton mentions something important here; the desire >> to actually detect if something is an array or arraylike to >> be able to branch to different code that does completely >> different things for array[li

Re: array like objects

2009-12-11 Thread Mark S. Miller
[+commonjs] On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson wrote: > Thanks Mark, this is the right way to approach it I think. String objects > will be considered array-like above which may not be desired, but either > way, I think it is this type of guideline that can prove valuable, so host >

RE: array like objects

2009-12-11 Thread Mike Wilson
Mark S. Miller wrote: If we're looking for a convention that is * does not admit any legacy ES3R non-array non-host objects (to prevent false positives) * does easily allow ES5 programmers to define new array-like non-array objects * takes bounded-by-constant time (i.e., no iteration) * is a re

Re: array like objects

2009-12-11 Thread Mark S. Miller
On Fri, Dec 11, 2009 at 2:27 AM, Mike Wilson wrote: > I think Breton mentions something important here; the desire > to actually detect if something is an array or arraylike to > be able to branch to different code that does completely > different things for array[likes] and objects. If we just >

RE: array like objects

2009-12-11 Thread Mike Wilson
} > > could be used as a valid arrayLike, and that seems reasonable to me. > > > > > > On Tue, Dec 8, 2009 at 1:18 PM, Allen Wirfs-Brock > wrote: > > Curiously, I don't believe any of the "generic" functions > for arrays and > > array-like

Re: array like objects

2009-12-08 Thread Brendan Eich
On Dec 8, 2009, at 12:52 PM, Mike Samuel wrote: 2009/12/8 Brendan Eich : On Dec 8, 2009, at 11:51 AM, Erik Corry wrote: for (let i in arraylike) { i |= 0; If this pattern catches on then we could optimize for it without changing the language. Yeah, but some day there will be only "new"

Re: array like objects

2009-12-08 Thread Mike Samuel
2009/12/8 Brendan Eich : > On Dec 8, 2009, at 11:51 AM, Erik Corry wrote: > >>> for (let i in arraylike) { >>>   i |= 0; >> >> If this pattern catches on then we could optimize for it without >> changing the language. > > Yeah, but some day there will be only "new" versions in which i is numeric >

Re: array like objects

2009-12-08 Thread Mike Samuel
2009/12/8 Brendan Eich : > On Dec 8, 2009, at 11:38 AM, Mike Samuel wrote: > >>> Agreed, but Erik's point here was about instanceof. Not only mutable >>> __proto__, but mutable bindings for constructors, and the issue of >>> multiple >>> global objects with their unrelated suites of builtin constru

Re: array like objects

2009-12-08 Thread Brendan Eich
On Dec 8, 2009, at 11:51 AM, Erik Corry wrote: for (let i in arraylike) { i |= 0; If this pattern catches on then we could optimize for it without changing the language. Yeah, but some day there will be only "new" versions in which i is numeric for arraylikes and that becomes pointless.

Re: array like objects

2009-12-08 Thread Erik Corry
2009/12/8 Brendan Eich : > On Dec 8, 2009, at 11:36 AM, Brendan Eich wrote: > >> Adding new syntax makes for-in a boat-anchor implementations lug around, >> in the best case. But realistically it will be years before developers can >> count on the new loop construct. And as support comes online, de

Re: array like objects

2009-12-08 Thread Brendan Eich
On Dec 8, 2009, at 11:38 AM, Mike Samuel wrote: Agreed, but Erik's point here was about instanceof. Not only mutable __proto__, but mutable bindings for constructors, and the issue of multiple global objects with their unrelated suites of builtin constructors, make instanceof less than idea

Re: array like objects

2009-12-08 Thread Brendan Eich
On Dec 8, 2009, at 11:36 AM, Brendan Eich wrote: Adding new syntax makes for-in a boat-anchor implementations lug around, in the best case. But realistically it will be years before developers can count on the new loop construct. And as support comes online, developers will have to choose w

Re: array like objects

2009-12-08 Thread Mike Samuel
2009/12/8 Brendan Eich : > On Dec 8, 2009, at 10:10 AM, Mike Samuel wrote: > >>> 1) Does the object have the special semantics around .length?  This is >>> potentially useful to know and the normal way to find out doesn't >>> work.  Instanceof is affected by setting __proto__, yet the special >>> .

Re: array like objects

2009-12-08 Thread Brendan Eich
Ok, let's think about a new loop construct. Adding new syntax makes for-in a boat-anchor implementations lug around, in the best case. But realistically it will be years before developers can count on the new loop construct. And as support comes online, developers will have to choose which

Re: array like objects

2009-12-08 Thread Juriy Zaytsev
On Dec 8, 2009, at 1:10 PM, Mike Samuel wrote: > 2009/12/8 Erik Corry : >> 2009/12/8 Mike Samuel : >>> It occurred to me after looking at the proxy strawman that it might >>> help to nail down what "array-like" means in future drafts. It isn't >>> directly related to the proxy stuff though so I

RE: array like objects

2009-12-08 Thread Allen Wirfs-Brock
-Original Message- From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Brendan Eich ... >If anyone knows of real-world code that would be broken by the type of the for-in loop variable not always being string, I'm all ears. >/be I don't have a real

Re: array like objects

2009-12-08 Thread Brendan Eich
On Dec 8, 2009, at 10:10 AM, Mike Samuel wrote: 1) Does the object have the special semantics around .length? This is potentially useful to know and the normal way to find out doesn't work. Instanceof is affected by setting __proto__, yet the special .length handling persists and instanceof

Re: array like objects

2009-12-08 Thread Mike Samuel
prototype.toString(input) === '[object Array]' >>    (3) input.length === (input.length >> 0) >> etc. > > These all look like failed attempts to answer one or both of the two > questions above. Agreed. Some more attempts below. >> >> The common th

Re: array like objects

2009-12-08 Thread Erik Corry
rent libraries defined array-like in different ways. > Some ways I've seen: >    (1) input instanceof Array >    (2) Object.prototype.toString(input) === '[object Array]' >    (3) input.length === (input.length >> 0) > etc. These all look like failed attempts to a

Re: array like objects

2009-12-07 Thread Brendan Eich
On Dec 7, 2009, at 6:24 PM, Mike Samuel wrote: 2009/12/7 Yehuda Katz : Your strawman would support: {0: "strawman", length: 0} A better definition might be: o is an array like object if o[[Get]]('length') returns a Number one greater than the largest numeric property, or 0 if no numeric

Re: array like objects

2009-12-07 Thread Mike Samuel
2009/12/7 Breton Slivka : > The one that I use is > > function isArrayLike(i){ >    return (typeof i !=="string") && i.length !== void (0); I like that it's efficient. How about if (i !== null && typeof i === 'object') { var len = i.length; var ilen = len >>> 0; return (len =

Re: array like objects

2009-12-07 Thread Mike Samuel
2009/12/7 Allen Wirfs-Brock : > Curiously, I don’t believe any of the “generic” functions for arrays and > array-like objects in section 15.4.4 actually depend upon such an > “array-like” test. They all simply use ToUint32 applied to the value of the > length property.  If the len

Re: array like objects

2009-12-07 Thread Breton Slivka
on’t believe any of the “generic” functions for arrays and > array-like objects in section 15.4.4 actually depend upon such an > “array-like” test. They all simply use ToUint32 applied to the value of the > length property. If the length property doesn’t exist or its value isn’t > somet

Re: array like objects

2009-12-07 Thread Breton Slivka
The one that I use is function isArrayLike(i){ return (typeof i !=="string") && i.length !== void (0); } It might not be perfect, but it allows me to make certain assumptions about the input that are useful enough. Keep in mind that an Array may have a length of 5, and all those values are un

Re: array like objects

2009-12-07 Thread Mike Samuel
1) input instanceof Array >>    (2) Object.prototype.toString(input) === '[object Array]' >>    (3) input.length === (input.length >> 0) >> etc. >> >> The common thread with array like objects is that they are meant to be >> iterated over in series. &

RE: array like objects

2009-12-07 Thread Allen Wirfs-Brock
Curiously, I don't believe any of the "generic" functions for arrays and array-like objects in section 15.4.4 actually depend upon such an "array-like" test. They all simply use ToUint32 applied to the value of the length property. If the length property doesn&#

Re: array like objects

2009-12-07 Thread Yehuda Katz
nt libraries defined array-like in different ways. > Some ways I've seen: >(1) input instanceof Array >(2) Object.prototype.toString(input) === '[object Array]' >(3) input.length === (input.length >> 0) > etc. > > The common thread with array like

array like objects

2009-12-07 Thread Mike Samuel
bject.prototype.toString(input) === '[object Array]' (3) input.length === (input.length >> 0) etc. The common thread with array like objects is that they are meant to be iterated over in series. It might simplify library code and reduce confusion among clients of these libraries if ther