Re: ES6 doesn't need opt-in

2012-01-03 Thread Gavin Barraclough
On Jan 2, 2012, at 11:45 PM, Axel Rauschmayer wrote: Prefix might work, too. ¿x? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Mariusz Nowak
Rick Waldron wrote: On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: I like it, it indeed looks very logical, however it's a bit controversial that we need to create temporary array object to get one that we want. Is the controversy editorial or

?? operator (was: ES6 doesn't need opt-in)

2012-01-03 Thread Axel Rauschmayer
?? would work better than ? in JavaScript, because it wouldn’t clash with the conditional operator in JavaScript Wouldn't it be possible to use a single '?' for all of them (the conditional, default and existential operators) and disambiguate between them according to the way they're

Re: ES6 doesn't need opt-in

2012-01-03 Thread Andreas Rossberg
On 3 January 2012 07:21, Brendan Eich bren...@mozilla.com wrote: It's not obvious if the static scope is built up from sript element to successive script element, either. Must I read all the scripts? The conditionally generated ones too? The top level is hard. The only way to be sure is to

Re: ES6 doesn't need opt-in

2012-01-03 Thread Andreas Rossberg
On 3 January 2012 07:19, Brendan Eich bren...@mozilla.com wrote: [Dave has been traveling, hope it's ok for me to jump in. /be] On Jan 2, 2012, at 6:07 AM, Andreas Rossberg wrote: In other words, I think the main points of your proposal can essentially be rephrased to: 1) Rename use

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Herby Vojčík
Hello, binary ftw. See http://jsperf.com/array-repeat/4 Array.prototype.repeatD. And I also tried push.apply in repeatC (not to copy over the array using concat but grow it in place until possible) and it really surprised me it was that much slower. Concat is probably heavily optimized.

Is private really private?

2012-01-03 Thread Herby Vojčík
Hello, form what I understood in the class proposal, I can write a code like this: (function () { return private(this).foo; }).apply(objectWithPrivateFoo); and it will work. Is it so? Isn’t then the notion of per-object private impossible having dynamic language with first-class function and

String.prototype.[de]normalize and .isCharXxx are needed

2012-01-03 Thread Herby Vojčík
Hello, in certain application, Unicode de/normalization and possibility to query what group the character is is vital, but ECMAScript does not have these methods nor did I see them in any of the proposals? Are they planned? Or can they be added? Thanks, Herby

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread felix
repeatD(10) returns 17 copies, not 10. On Tue, Jan 3, 2012 at 4:28 AM, Herby Vojčík he...@mailbox.sk wrote: Hello, binary ftw. See http://jsperf.com/array-repeat/4 Array.prototype.repeatD. And I also tried push.apply in repeatC (not to copy over the array using concat but grow it in place

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Rick Waldron
On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: I like it, it indeed looks very logical, however it's a bit controversial that we need

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Herby Vojčík
Sorry, fixed (you get the idea, anyway, doing 10 concats is worse than doing five of them, with _big_ chunks of data in the last calls). There is a checking throw in the end so it really works now. Now it is even more faster :-) Herby -Pôvodná správa- From: felix Sent: Tuesday,

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Mariusz Nowak
Rick Waldron wrote: On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: I like it, it indeed looks very logical, however it's a bit

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Rick Waldron
On Tue, Jan 3, 2012 at 9:19 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak

Re: Array.prototype.contains

2012-01-03 Thread Greg Smith
I see Array.contains as a great idea. This is an operation I use constantly when I write code and it'd be nice to have it be a first class Array operation. Sure it's not so different than indexOf, but the semantics are much more intuitive and it may very well be the more common operation. -Greg

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Greg Smith
What is the use case for .repeat? Trying to imagine some code where I'd need it so I can get a feel for how it should work. On Tue, Jan 3, 2012 at 9:19 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak

Re: Array.prototype.contains

2012-01-03 Thread Greg Smith
Sorry I meant Array.prototype.contains On Tue, Jan 3, 2012 at 9:46 AM, Greg Smith g...@bocoup.com wrote: I see Array.contains as a great idea. This is an operation I use constantly when I write code and it'd be nice to have it be a first class Array operation. Sure it's not so different than

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Mariusz Nowak
Rick Waldron wrote: On Tue, Jan 3, 2012 at 9:19 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Mon, Jan 2, 2012 at 3:56 PM,

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Rick Waldron
On Tue, Jan 3, 2012 at 10:16 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Tue, Jan 3, 2012 at 9:19 AM, Mariusz Nowak medikoo+mozilla@medikoo.com wrote: Rick Waldron wrote: On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak

Re: Is private really private?

2012-01-03 Thread Mark S. Miller
*Only* if that code appears appears within the text of the class of which objectWithPrivateFoo is an instance. foo is what we call a class private instance variable, which is essentially the same degree of encapsulation as Java's private fields -- instances of the class can see into other

Re: Is private really private?

2012-01-03 Thread Herby Vojčík
Hello, *Only* if that code appears appears within the text of the class ClassWithPrivateFoo means only inside class {...} block that defines ClassWithPrivateFoo? So ES.next private could be seen as sugar for lexical private in scope of class block? Herby -Pôvodná správa- From:

Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Axel Rauschmayer
On Jan 3, 2012, at 15:46 , Greg Smith wrote: What is the use case for .repeat? Trying to imagine some code where I'd need it so I can get a feel for how it should work. So beauty alone does not count? ;-) It’s true – there are not a lot of use cases for Array.repeat(). But I keep thinking

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Rick Waldron
I think it's fairly common for range implementations to provide an optional `step` parameter On Tue, Jan 3, 2012 at 12:08 PM, Axel Rauschmayer a...@rauschma.de wrote: On Jan 3, 2012, at 15:46 , Greg Smith wrote: What is the use case for .repeat? Trying to imagine some code where I'd need it

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Axel Rauschmayer
I think it's fairly common for range implementations to provide an optional `step` parameter Good point. Maybe all of these parameters should be options: Array.range() - 0, 1, 2, 3, ... Array.range({ start: 3 }) - 3, 4, 5, 6, ... Array.range({ end: 5 }) - 0, 1, 2, 3, 4 Array.range({ step: 3

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Sean Eagan
I think step should be 0, and step towards end: Array.range({start: 5, end: 0, step: 2}) - 5, 3, 1 On Tue, Jan 3, 2012 at 11:42 AM, Axel Rauschmayer a...@rauschma.de wrote: I think it's fairly common for range implementations to provide an optional `step` parameter Good point. Maybe all of

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Axel Rauschmayer
Either way is fine with me. But it’s probably best to copy Python’s semantics: http://docs.python.org/py3k/library/functions.html#range On Jan 3, 2012, at 18:50 , Sean Eagan wrote: I think step should be 0, and step towards end: Array.range({start: 5, end: 0, step: 2}) - 5, 3, 1 On Tue,

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Adam Shannon
I would be more in favor of something like the code below, its just a proof of concept. Array.prototype.range = function (value, start, end, step) { if (typeof value === number) { end = (start = 0 value = 0) ? Math.min(value, start) : 0; start = (start = 0 value = 0) ?

Proposal: Signed variables

2012-01-03 Thread Adam Shannon
When working on Array.prototype.range (among many others) I noticed that being able to specify the sign of a numeric would quicken code's readability. Take the following proof of concept from Array.prototype.range and compare it to the signed variable example. Array.prototype.range = function

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Rick Waldron
On Tue, Jan 3, 2012 at 12:50 PM, Sean Eagan seaneag...@gmail.com wrote: I think step should be 0, and step towards end: Array.range({start: 5, end: 0, step: 2}) - 5, 3, 1 This would be an unfortunate limitation, considering real world impl's allow negative numbers...

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Maël Nison
Good point. Maybe all of these parameters should be options: Array.range() - 0, 1, 2, 3, ... Array.range({ start: 3 }) - 3, 4, 5, 6, ... Array.range({ end: 5 }) - 0, 1, 2, 3, 4 Array.range({ step: 3 }) - 0, 3, 6, 9, ... Array.range({ start: -2, step: -1 }) - -2, -3, -4, -5, ... etc. Why

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Michael A. Smith
When I first started learning JavaScript I didn't understand how new Array(n); worked, in that it creates an empty array with a length of n. What I had expected was an array with n values (even if it wasn't well-defined what those values should be). So of course my attempt to create an array of

Re: Suggestion: Array.prototype.repeat

2012-01-03 Thread Nadav Shesek
Sorry - I had my email address misconfigured so it rejected my email. Sending it again: Added my own repeatF() to the tests at http://jsperf.com/array-repeat/6. Seems to be much faster than the others, at least on V8. On Tue, Jan 3, 2012 at 2:28 PM, Herby Vojčík he...@mailbox.sk wrote:

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 1:29 AM, Andreas Rossberg wrote: On 3 January 2012 07:21, Brendan Eich bren...@mozilla.com wrote: It's not obvious if the static scope is built up from sript element to successive script element, either. Must I read all the scripts? The conditionally generated ones too?

Re: Is private really private?

2012-01-03 Thread Mark S. Miller
On Tue, Jan 3, 2012 at 8:45 AM, Herby Vojčík he...@mailbox.sk wrote: Hello, *Only* if that code appears appears within the text of the class ClassWithPrivateFoo means only inside class {...} block that defines ClassWithPrivateFoo? So ES.next private could be seen as sugar for lexical

Re: ES6 doesn't need opt-in

2012-01-03 Thread Allen Wirfs-Brock
On Jan 3, 2012, at 12:01 PM, Brendan Eich wrote: On Jan 3, 2012, at 1:29 AM, Andreas Rossberg wrote: ... For multi-part scripts we need a way to switch the _proper_ top-level into extended mode. Or should I not be able to write (the relevant bits of) a multi-part script in extended

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 1:29 AM, Andreas Rossberg wrote: On 3 January 2012 07:19, Brendan Eich bren...@mozilla.com wrote: [Dave has been traveling, hope it's ok for me to jump in. /be] On Jan 2, 2012, at 6:07 AM, Andreas Rossberg wrote: In other words, I think the main points of your proposal

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 12:16 PM, Allen Wirfs-Brock wrote: On Jan 3, 2012, at 12:01 PM, Brendan Eich wrote: On Jan 3, 2012, at 1:29 AM, Andreas Rossberg wrote: ... For multi-part scripts we need a way to switch the _proper_ top-level into extended mode. Or should I not be able to write

Make method semantic identical in classes and literals

2012-01-03 Thread Herby Vojčík
Hello, overall I believe in making classes and literals as close as possible. I think at least semantics of things they have in common should be identical. In http://wiki.ecmascript.org/doku.php?id=harmony:classes, this is written: By default, data properties define enumerable prototype

Re: ES6 doesn't need opt-in

2012-01-03 Thread Gavin Barraclough
On Jan 3, 2012, at 12:18 PM, Brendan Eich wrote: Maybe. We tried in 2006-2007 and ran into at least this: https://bugzilla.mozilla.org/show_bug.cgi?id=351515 where 'yield' was used as a parameter name. I dimly recall 'let' in the wild but may be misremembering. Perhaps out of paranoia we

Re: ES6 doesn't need opt-in

2012-01-03 Thread Mark S. Miller
Just Two Modes This is a long thread and I've been completely busy with other things so have not had time to do more than skim. So please understand if the post below misses some context. The following is a summary of some principles that Dave and just agreed to in a

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 12:28 PM, Gavin Barraclough wrote: On Jan 3, 2012, at 12:18 PM, Brendan Eich wrote: Maybe. We tried in 2006-2007 and ran into at least this: https://bugzilla.mozilla.org/show_bug.cgi?id=351515 where 'yield' was used as a parameter name. I dimly recall 'let' in the

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 1:24 PM, Mark S. Miller wrote: Just Two Modes V8 folks the other year had a catchier version: no more modes. * ES6 non-strict mode must be practically upwards compatible from ES5 non-strict mode. This is the part that's not clearly agreed to,

Re: ES6 doesn't need opt-in

2012-01-03 Thread Gavin Barraclough
On Jan 3, 2012, at 3:27 PM, Brendan Eich wrote: You're proposing that we require 'let' be only at the start of statements? If so, then destructuring is problematic: foo(); let [x] = y; Did that last line destructure the property named '0' of the object denoted by y into a

Re: ES6 doesn't need opt-in

2012-01-03 Thread Allen Wirfs-Brock
On Jan 3, 2012, at 4:31 PM, Gavin Barraclough wrote: On Jan 3, 2012, at 3:27 PM, Brendan Eich wrote: You're proposing that we require 'let' be only at the start of statements? If so, then destructuring is problematic: foo(); let [x] = y; Did that last line destructure the property

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 4:31 PM, Gavin Barraclough wrote: On Jan 3, 2012, at 3:27 PM, Brendan Eich wrote: You're proposing that we require 'let' be only at the start of statements? If so, then destructuring is problematic: foo(); let [x] = y; Did that last line destructure the property

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 4:38 PM, Allen Wirfs-Brock wrote: ArrayBindingPattern : [ Elisionopt BindingRestElementopt ] [ BindingElementList , Elisionopt BindingRestElementopt ] It's a grammar bug. Thanks for the proof reading... The final opt cited above is the bug, right? The first

Re: ES6 doesn't need opt-in

2012-01-03 Thread Gavin Barraclough
On Jan 3, 2012, at 4:42 PM, Brendan Eich wrote: On Jan 3, 2012, at 4:38 PM, Allen Wirfs-Brock wrote: ArrayBindingPattern : [ Elisionopt BindingRestElementopt ] [ BindingElementList , Elisionopt BindingRestElementopt ] It's a grammar bug. Thanks for the proof reading... The

Re: ES6 doesn't need opt-in

2012-01-03 Thread Allen Wirfs-Brock
On Jan 3, 2012, at 4:42 PM, Brendan Eich wrote: On Jan 3, 2012, at 4:38 PM, Allen Wirfs-Brock wrote: ArrayBindingPattern : [ Elisionopt BindingRestElementopt ] [ BindingElementList , Elisionopt BindingRestElementopt ] It's a grammar bug. Thanks for the proof reading... The

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 4:50 PM, Gavin Barraclough wrote: On Jan 3, 2012, at 4:42 PM, Brendan Eich wrote: On Jan 3, 2012, at 4:38 PM, Allen Wirfs-Brock wrote: ArrayBindingPattern : [ Elisionopt BindingRestElementopt ] [ BindingElementList , Elisionopt BindingRestElementopt ] It's a

Re: ES6 doesn't need opt-in

2012-01-03 Thread Gavin Barraclough
Ah, I see! - Thanks. On Jan 3, 2012, at 4:58 PM, Brendan Eich wrote: On Jan 3, 2012, at 4:50 PM, Gavin Barraclough wrote: On Jan 3, 2012, at 4:42 PM, Brendan Eich wrote: On Jan 3, 2012, at 4:38 PM, Allen Wirfs-Brock wrote: ArrayBindingPattern : [ Elisionopt BindingRestElementopt ]

Re: ES6 doesn't need opt-in

2012-01-03 Thread Mark S. Miller
On Tue, Jan 3, 2012 at 4:08 PM, Brendan Eich bren...@mozilla.com wrote: On Jan 3, 2012, at 1:24 PM, Mark S. Miller wrote: Just Two Modes V8 folks the other year had a catchier version: no more modes. I am happy with that ;). * ES6 non-strict mode must be

Re: ES6 doesn't need opt-in

2012-01-03 Thread Brendan Eich
On Jan 3, 2012, at 9:52 PM, Mark S. Miller wrote: A good example. Since the class proposal uses private, public, static, by these principles, it would only be recognized in strict mode. If it appears in non-strict code, it would be a SyntaxError. That's a choice. I'm asking why it's the

Re: ES6 doesn't need opt-in

2012-01-03 Thread Mark S. Miller
On Tue, Jan 3, 2012 at 10:18 PM, Brendan Eich bren...@mozilla.com wrote: On Jan 3, 2012, at 9:52 PM, Mark S. Miller wrote: A good example. Since the class proposal uses private, public, static, by these principles, it would only be recognized in strict mode. If it appears in non-strict