Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
Hello, How likely (based on backward compats) that Harmony will support Pythonic negative indices for arrays? Ruby supports them too. There was previous indirect mention, were Brendan agreed that Harmony needs such a semantics for arrays, however, that discussion wasn't formed to something

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 11.11.2010 13:24, Dmitry A. Soshnikov wrote: There was previous indirect mention, were Brendan agreed that Harmony needs such a semantics for arrays Sorry, forgot the link https://mail.mozilla.org/pipermail/es-discuss/2010-May/05.html

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 11.11.2010 13:24, Dmitry A. Soshnikov wrote: Toughs? Funny typo :D Sorry. Thoughts? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
Actually, I'm still not sure myself whether I want this semantics in JS for arrays. I remember one case (some simple math task) when I was needed a[-1] and was glad that JS supports it -- I used `for (var i = -2; i 10; i++) a[i]`, and it was very elegant decision at that moment. There is

Re: Negative indices for arrays

2010-11-11 Thread Oliver Hunt
On Nov 11, 2010, at 11:30 AM, Dmitry A. Soshnikov wrote: OTOH, negative indices, are even not array indices. I.e. var a = [1,2]; a[-1] = 0; print(a); // 1,2 print(a.length); // 2 From this viewpoint -- for what are they? Seems again, `-n` notations for arrays and strings is useful as

Re: Negative indices for arrays

2010-11-11 Thread Ash Berlin
On 11 Nov 2010, at 19:30, Dmitry A. Soshnikov wrote: OTOH, negative indices, are even not array indices. I.e. var a = [1,2]; a[-1] = 0; print(a); // 1,2 print(a.length); // 2 From this viewpoint -- for what are they? Seems again, `-n` notations for arrays and strings is useful as a

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 11.11.2010 22:39, Ash Berlin wrote: On 11 Nov 2010, at 19:30, Dmitry A. Soshnikov wrote: OTOH, negative indices, are even not array indices. I.e. var a = [1,2]; a[-1] = 0; print(a); // 1,2 print(a.length); // 2 From this viewpoint -- for what are they? Seems again, `-n` notations for

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 11.11.2010 22:39, Oliver Hunt wrote: On Nov 11, 2010, at 11:30 AM, Dmitry A. Soshnikov wrote: OTOH, negative indices, are even not array indices. I.e. var a = [1,2]; a[-1] = 0; print(a); // 1,2 print(a.length); // 2 From this viewpoint -- for what are they? Seems again, `-n` notations

RE: Negative indices for arrays

2010-11-11 Thread Allen Wirfs-Brock
From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Dmitry A. Soshnikov ... Yes, I mentioned it myself several times (in articles and including several topics in es-discuss). Yes, Python distinguish. Ruby too. But from your position, ES already has some

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 12.11.2010 0:07, Allen Wirfs-Brock wrote: From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Dmitry A. Soshnikov ... Yes, I mentioned it myself several times (in articles and including several topics in es-discuss). Yes, Python distinguish. Ruby too.

RE: Negative indices for arrays

2010-11-11 Thread Peter van der Zee
If harmony would introduce this syntax guarded under a new script type, there would at least be no danger of breaking the web (existing scripts). However, negative array indexes might cause confusion when doing so implicitly. If you asume array indexes are just properties it'll be hard to

Re: Negative indices for arrays

2010-11-11 Thread Oliver Hunt
So, do I understand correctly that you are against this feature and don't like it? (Just another question -- are you aware that it used in Python, Ruby, Perl, Coffee, other langs?) The fact that other languages have a feature is not relevant, the problem is the drastic change to semantics

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 12.11.2010 0:42, Peter van der Zee wrote: If harmony would introduce this syntax guarded under a new script type, there would at least be no danger of breaking the web (existing scripts). I don't think it means that using script type=harmony we may do everything (i.e. completely different

Re: Negative indices for arrays

2010-11-11 Thread Dmitry A. Soshnikov
On 12.11.2010 0:47, Oliver Hunt wrote: So, do I understand correctly that you are against this feature and don't like it? (Just another question -- are you aware that it used in Python, Ruby, Perl, Coffee, other langs?) The fact that other languages have a feature is not relevant, the problem

RE: Negative indices for arrays

2010-11-11 Thread Allen Wirfs-Brock
-Original Message- From: Dmitry A. Soshnikov [mailto:dmitry.soshni...@gmail.com] ... Yeah, it's possible to make this thing generic, though maybe also good only for arrays. Need to more discuss, think. There isn't actually all that much difference between array instances and

RE: Negative indices for arrays

2010-11-11 Thread Allen Wirfs-Brock
-Original Message- From: Peter van der Zee [mailto:e...@qfox.nl] ... I guess I would like -n to map to length-n, but I'm not sure whether it's worth the cost described above. After all, it's just sugar. Like Oliver also said. This isn't just sugar, it is a deep semantic change to

Re: Negative indices for arrays

2010-11-11 Thread David Herman
If harmony would introduce this syntax guarded under a new script type, there would at least be no danger of breaking the web (existing scripts). That sounds like an interop nightmare -- you're talking about forking the Array type between language versions. Keep in mind that non-Harmony and

Re: Negative indices for arrays

2010-11-11 Thread Brendan Eich
I agree with Dave, Allen, and Oliver that we should not just change indexing under Harmony script-type opt-in. Note also that Python, at least, has a more elaborate system of slicing that has evolved over the years. I added slice in the Netscape 4 era, which made it into ES3 and has the

Function declarations as statements

2010-11-11 Thread Michael Day
Hi, In ECMAScript, function declarations are SourceElements, but not Statements. This means that they can only occur at the top level, and may not be nested inside a block. However, browsers support function declarations as statements, and many scripts on the web seem to make use of this

RE: Function declarations as statements

2010-11-11 Thread Allen Wirfs-Brock
From the ES5 spec section 12 statement semantics: NOTESeveral widely used implementations of ECMAScript are known to support the use of FunctionDeclaration as a Statement. However there are significant and irreconcilable variations among the implementations in the semantics applied to such

Re: Function declarations as statements

2010-11-11 Thread Michael Day
Hi Brendan and Allen, Thanks for the pointers. So for Harmony, we are reclaiming function in block (must be a direct child of a braced block) to bind a block-local name on block entry (so hoisting lives, but only to top of block -- so you can't emulate with var f = function ...). If we

RE: Function declarations as statements

2010-11-11 Thread Allen Wirfs-Brock
I believe that would be interoperable as long as each such function is only declared and used within a single block. Multiple declarations with the same function name in separate blocks wouldn't be interoperable among all browsers. Allen -Original Message- From: Michael Day

Re: Function declarations as statements

2010-11-11 Thread Mark S. Miller
On Thu, Nov 11, 2010 at 5:10 PM, Allen Wirfs-Brock allen.wirfs-br...@microsoft.com wrote: I believe that would be interoperable as long as each such function is only declared and used within a single block. Multiple declarations with the same function name in separate blocks wouldn't be

Re: Function declarations as statements

2010-11-11 Thread Garrett Smith
On 11/11/10, Michael Day mike...@yeslogic.com wrote: Hi Brendan and Allen, Thanks for the pointers. So for Harmony, we are reclaiming function in block (must be a direct child of a braced block) to bind a block-local name on block entry (so hoisting lives, but only to top of block -- so you

Re: Function declarations as statements

2010-11-11 Thread Mark S. Miller
On Thu, Nov 11, 2010 at 5:37 PM, Garrett Smith dhtmlkitc...@gmail.comwrote: On 11/11/10, Michael Day mike...@yeslogic.com wrote: Hi Brendan and Allen, Thanks for the pointers. So for Harmony, we are reclaiming function in block (must be a direct child of a braced block) to bind a

{ and } in regexps

2010-11-11 Thread Michael Day
Hi, Browsers seem to allow { and } to occur in regexps unescaped, if the position does not conflict with their use as a quantifier. For example: /foo|{bar}/ However, ES3 and ES5 forbid this, as PatternCharacter does not include { or } or any of the other significant punctuation. Given