Re: ECMAScript.next features in Firefox?

2012-01-02 Thread Andreas Rossberg
On 25 December 2011 13:26, Axel Rauschmayer a...@rauschma.de wrote: Paul Irish did a code search for that: http://www.google.com/codesearch#W9JxUuHYyMg/trunk/src/flag-definitions.hq=harmony%20package:http://v8\.googlecode\.coml=109 To elaborate, the --harmony flag currently activates the

Re: Maps and WeakMaps interoperability

2012-01-02 Thread Andreas Rossberg
On 27 December 2011 16:15, David Bruant bruan...@gmail.com wrote: - var m = new Map(); var key = {}; m.set(key, 37); WeakMap.prototype.get.call(m, key); // ? - Currently Chrome canary says illegal access. That is a bug. It should throw TypeError. /Andreas

Re: Simple maps/sets: parameterize the comparator?

2012-01-02 Thread Andreas Rossberg
On 29 December 2011 18:48, Allen Wirfs-Brock al...@wirfs-brock.com wrote: The existence of WeakMap/Map implies the existence of an internal object identify hash value. Why? AFAICT, there is nothing currently requiring these collections to be implemented as hash tables in particular. And there

Re: Why we need to clean up __proto__

2012-01-02 Thread Andreas Rossberg
On 30 December 2011 00:00, Mark S. Miller erig...@google.com wrote: {__proto__:...} having a magic meaning is per code, and so can and should be conditioned on mode. I think it should only be allowed to be magic in non-strict mode. What about {[__proto__]: ...} then? /Andreas

Re: ES6 doesn't need opt-in

2012-01-02 Thread Andreas Rossberg
It sure would be nice to put away with additional language modes. However: Pragmatically, I don't see how wrapping your program into a module is more convenient then putting a `use' directive on top. And your additional proposal for use module is kind of admitting that it's actually worse, isn't

String.prototype.until

2012-01-02 Thread Adam Shannon
Hello all, I recently ran into a situation where I would like to obtain a substring from the beginning until the first encounter with another substring. This promoted me to write a simple function, called until and I wondered if it would be something to add with the other string extras for

Re: Object Model Reformation – elementIn?

2012-01-02 Thread Allen Wirfs-Brock
On Jan 1, 2012, at 5:54 AM, Axel Rauschmayer wrote: http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation Currently, there one can override the built-in operators via elementGet (getting via []), elementSet (setting via []) and elementDelete (`delete` operator).

Re: Object Model Reformation – elementIn?

2012-01-02 Thread Axel Rauschmayer
Currently, there one can override the built-in operators via elementGet (getting via []), elementSet (setting via []) and elementDelete (`delete` operator). Wouldn’t it make sense to also provide elementIn (`in` operator)? Probably. It may depend upon how strongly you feel about

Re: String.prototype.until

2012-01-02 Thread Michael A. Smith
Semantically, calling it until makes me think that if the needle isn't found, it should return the entire haystack. Your example implementation would return an empty string in that case. Also, to keep consistency with other string methods like substr, shouldn't we allow the developer to decide the

Re: String.prototype.until

2012-01-02 Thread Axel Rauschmayer
Isn’t that usually better handled via a regular expression? One of the use cases for quasis [1][2] is to make it easy to insert literal text into a regular expression. That seems pertinent here. Example: re`\d+(${localeSpecificDecimalPoint}\d+)?` The text in the variable

Re: String.prototype.until

2012-01-02 Thread Adam Shannon
Yes, I see the use for returning the entire string if the needle isn't found. I was also thinking about a dynamic start position, which is why I'd favor something like this. String.prototype.until = function (needle, start) { start ?? 0; return this.substr(start, this.indexOf(needle)) ||

Re: String.prototype.until

2012-01-02 Thread Adam Shannon
Alex, I'm confused as to what regular expressions would help with in this case. (Over .indexOf) The idea of .util() would be to return a new string which is just a substring, but provided as an ease of use to the developer. The case where I wrote .util() was in parsing out two comma separated

Re: String.prototype.until

2012-01-02 Thread Axel Rauschmayer
/^(.*?)needle.*$/.exec(foobar_needle)[1] 'foobar_' On Jan 2, 2012, at 19:04 , Adam Shannon wrote: Alex, I'm confused as to what regular expressions would help with in this case. (Over .indexOf) The idea of .util() would be to return a new string which is just a substring, but provided as an

Suggestion: Array.prototype.repeat

2012-01-02 Thread Axel Rauschmayer
Array.prototype.repeat seems like a logical dual to String.prototype.repeat: http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat Implementation: Array.prototype.repeat = function (times) { var result = []; var len = this.length; var resultLen =

Re: Suggestion: Array.prototype.repeat

2012-01-02 Thread Mariusz Nowak
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. Function (not method) that returns generated array may make more sense, currently I'm using something like that: var slice = Array.prototype.slice;

Re: Suggestion: Array.prototype.repeat

2012-01-02 Thread Michael A. Smith
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. Function (not method) that returns generated array may make more

Re: Suggestion: Array.prototype.repeat

2012-01-02 Thread Adam Shannon
Another thing to think about is that .repeat (both on String and Array) will be used a lot in production. So it would make sense for each solution to be optimized for their specific case. It doesn't make sense to slow down something as trivial as .repeat() On Mon, Jan 2, 2012 at 16:51, Michael A.

Re: ES6 doesn't need opt-in

2012-01-02 Thread Gavin Barraclough
Hey Dave, I'm definitely in favour of removing the opt-in (or at least commonly removing the need to opt-in), and support the goal of one JS. Since most of the new syntax only relies on reserved words and, as Brendon stated, yield is only valid in function* constructs, the only problem so

Re: Suggestion: Array.prototype.repeat

2012-01-02 Thread Rick Waldron
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 fact, because the following

Re: Suggestion: Array.prototype.repeat

2012-01-02 Thread Rick Waldron
On Mon, Jan 2, 2012 at 5:55 PM, Adam Shannon a...@ashannon.us wrote: Another thing to think about is that .repeat (both on String and Array) will be used a lot in production. So it would make sense for each solution to be optimized for their specific case. It doesn't make sense to slow down

Re: ES6 doesn't need opt-in

2012-01-02 Thread Axel Rauschmayer
({ define: typeof define === function ? define // browser : function(F) { F(require,exports,module) } }). // Node.js define(function (require, exports, module) { // Node.js module code goes here }); Sure, but in that case the test typeof define ===

Re: ES6 doesn't need opt-in

2012-01-02 Thread Brendan Eich
[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 version 6 to use module. 2) Allow module declarations in classic mode.

Re: ES6 doesn't need opt-in

2012-01-02 Thread Brendan Eich
On Jan 1, 2012, at 5:12 AM, David Bruant wrote: Moreover, the concept of static scoping and just look at the code to see if a variable is declared is not that obvious for newcomers to the language or newcomers to programming. It's not obvious if the static scope is built up from sript

Re: ES6 doesn't need opt-in

2012-01-02 Thread Axel Rauschmayer
Right. Maybe the operator should have a different name. isDefined? has a value expressed as an operator name? isDefined x would be syntactic sugar for typeof x !== undefined x !== null The expression would not throw an exception if x hasn’t been declared. What about