Re: Destructuring for Array-like objects

2019-03-22 Thread guest271314
{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' ? > >> >> On Wed, Mar 20, 2019 at 12:59 AM Sultan wrote: &

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: > >> Afford array destructuring to Array-like ob

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

Re: Intercepting sets on array-like objects

2017-06-09 Thread Domenic Denicola
many other opinions from other TC39 members. From: "Tab Atkins Jr." <jackalm...@gmail.com> 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

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

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: > > *

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]`

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!

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 ,

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 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 might be

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

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

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 subclasses of Array. That

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

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 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

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. [...] Sorry, I

Re: array like objects

2009-12-14 Thread Mike Samuel
2009/12/13 Garrett Smith dhtmlkitc...@gmail.com: On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel mikesam...@gmail.com wrote: 2009/12/12 Garrett Smith dhtmlkitc...@gmail.com: On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller erig...@google.com wrote: On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith

Re: array like objects

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

Re: array like objects

2009-12-14 Thread Breton Slivka
On Tue, Dec 15, 2009 at 6:29 AM, Mike Samuel mikesam...@gmail.com 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

Re: array like objects

2009-12-14 Thread Mike Samuel
2009/12/14 Breton Slivka z...@zenpsycho.com: On Tue, Dec 15, 2009 at 6:29 AM, Mike Samuel mikesam...@gmail.com 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

Re: array like objects

2009-12-14 Thread Breton Slivka
On Tue, Dec 15, 2009 at 10:34 AM, Mike Samuel mikesam...@gmail.com wrote: 2009/12/14 Breton Slivka z...@zenpsycho.com: On Tue, Dec 15, 2009 at 6:29 AM, Mike Samuel mikesam...@gmail.com wrote: (3) If (!1), should future EcmaScript drafts define iteration order for arrays as index order and

Re: array like objects

2009-12-14 Thread Garrett Smith
On Mon, Dec 14, 2009 at 11:29 AM, Mike Samuel mikesam...@gmail.com wrote: 2009/12/14 Garrett Smith dhtmlkitc...@gmail.com: On Mon, Dec 14, 2009 at 9:34 AM, Mike Samuel mikesam...@gmail.com wrote: 2009/12/13 Garrett Smith dhtmlkitc...@gmail.com: On Sun, Dec 13, 2009 at 10:31 AM, Mike Samuel

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 dhtmlkitc...@gmail.com 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*

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) 0 === len); } If

Re: array like objects

2009-12-12 Thread Garrett Smith
On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson mike...@hotmail.com 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

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 mikesam...@gmail.com 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

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 mikesam...@gmail.com wrote: On the String defect, we could repair that with ({}).toString.call(obj) !== '[object String]' Cons: An extra function call in the likely

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 mike...@hotmail.com: 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 Garrett Smith
On Sat, Dec 12, 2009 at 12:01 PM, Mark S. Miller erig...@google.com wrote: On Sat, Dec 12, 2009 at 11:21 AM, Garrett Smith dhtmlkitc...@gmail.com wrote: On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson mike...@hotmail.com wrote: Mark S. Miller wrote: If we're looking for a convention that

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 12:29 PM, Garrett Smith dhtmlkitc...@gmail.comwrote: 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

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 12:29 PM, Garrett Smith dhtmlkitc...@gmail.com 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

Re: array like objects

2009-12-12 Thread Mark S. Miller
On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith dhtmlkitc...@gmail.comwrote: On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller erig...@google.com 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

Re: array like objects

2009-12-12 Thread Mike Samuel
2009/12/12 Brendan Eich bren...@mozilla.com: On Dec 12, 2009, at 10:36 AM, Mike Samuel wrote: 2009/12/12 Mike Wilson mike...@hotmail.com: 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 Mike Samuel
2009/12/12 Garrett Smith dhtmlkitc...@gmail.com: On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson mike...@hotmail.com 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

Re: array like objects

2009-12-12 Thread Garrett Smith
On Sat, Dec 12, 2009 at 4:04 PM, Mark S. Miller erig...@google.com wrote: On Sat, Dec 12, 2009 at 3:38 PM, Garrett Smith dhtmlkitc...@gmail.com wrote: On Sat, Dec 12, 2009 at 2:59 PM, Mark S. Miller erig...@google.com wrote: Are we really this stuck? Can anyone think of a reliable,

RE: array like objects

2009-12-11 Thread Mike Wilson
at 1:18 PM, Allen Wirfs-Brock allen.wirfs-br...@microsoft.com wrote: 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

Re: array like objects

2009-12-11 Thread Mark S. Miller
On Fri, Dec 11, 2009 at 2:27 AM, Mike Wilson mike...@hotmail.com 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

Re: array like objects

2009-12-11 Thread Mark S. Miller
[+commonjs] On Fri, Dec 11, 2009 at 12:08 PM, Mike Wilson mike...@hotmail.com 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

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 mike...@hotmail.com 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

Re: array like objects

2009-12-08 Thread Erik Corry
instanceof Array    (2) Object.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. The common thread with array like objects is that they are meant to be iterated over

Re: array like objects

2009-12-08 Thread Mike Samuel
) input instanceof Array    (2) Object.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 thread with array like

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 erik.co...@gmail.com: 2009/12/8 Mike Samuel mikesam...@gmail.com: 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

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 Mike Samuel
2009/12/8 Brendan Eich bren...@mozilla.com: 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

Re: array like objects

2009-12-08 Thread Mike Samuel
2009/12/8 Brendan Eich bren...@mozilla.com: 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 Brendan Eich
On Dec 8, 2009, at 12:52 PM, Mike Samuel wrote: 2009/12/8 Brendan Eich bren...@mozilla.com: 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

Re: array like objects

2009-12-07 Thread Yehuda Katz
) 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. It might simplify library code and reduce confusion among clients

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't exist or its value isn't something

Re: array like objects

2009-12-07 Thread Mike Samuel
value pairs   } but different 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 objects

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

Re: array like objects

2009-12-07 Thread Breton Slivka
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 something that an a convertible

Re: array like objects

2009-12-07 Thread Mike Samuel
2009/12/7 Allen Wirfs-Brock allen.wirfs-br...@microsoft.com: 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

Re: array like objects

2009-12-07 Thread Mike Samuel
2009/12/7 Breton Slivka z...@zenpsycho.com: 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