Re: why is regexp /\-/u a syntax-error?

2019-09-20 Thread Mathias Bynens
Think of the `u` flag as a strict mode for regular expressions. `/\a/u` throws, because there is no reason to escape `a` as `\a` -- therefore, if such an escape sequence is present, it's likely a user error. The same goes for `/\-/u`. `-` only has special meaning within character classes, not

Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread Mathias Bynens
Prior discussion from 7 years ago: https://esdiscuss.org/topic/how-to-count-the-number-of-symbols-in-a-string [...string].length does what you want. But it's definitely not always what you need . On Thu, Aug 8, 2019 at

Re: Overload str.replace to take a Map?

2018-05-20 Thread Mathias Bynens
p) { > break; > } > value = value[arg0](); > break; > } > }); > value = String(value); > // default to htmlSafe > if (!notHtmlSafe) { > value = value &

Re: Overload str.replace to take a Map?

2018-05-19 Thread Mathias Bynens
Hey Kai, you’re oversimplifying. Your solution works for a single Unicode symbol (corresponding to a single code point) but falls apart as soon as you need to match multiple symbols of possibly varying length, like in the `escapeHtml` example. On Sat, May 19, 2018 at 8:43 AM, kai zhu

Re: add reverse() method to strings

2018-03-18 Thread Mathias Bynens
n Sun, Mar 18, 2018 at 2:38 PM, Frederick Stark <coagm...@gmail.com> >>> wrote: >>> >>>> The point of a coding task for a beginner is to practice their problem >>>> solving skills to solve the task. This would remove the challenge and >>>> actively

Re: add reverse() method to strings

2018-03-17 Thread Mathias Bynens
So far no one has provided a real-world use case. On Mar 18, 2018 10:15, "Mike Samuel" wrote: > Previous discussion: https://esdiscuss.org/topic/wiki-updates-for-string- > number-and-math-libraries#content-1 > > """ > String.prototype.reverse(), as proposed, corrupts

Re: JSON.canonicalize()

2018-03-16 Thread Mathias Bynens
On Fri, Mar 16, 2018 at 9:04 PM, Mike Samuel wrote: > > The output of JSON.canonicalize would also not be in the subset of JSON > that is also a subset of JavaScript's PrimaryExpression. > >JSON.canonicalize(JSON.stringify("\u2028\u2029")) === `"\u2028\u2029"` > Soon

Re: Ranges

2016-11-04 Thread Mathias Bynens
On Fri, Nov 4, 2016 at 6:24 PM, Jordan Harband wrote: > Here you go: > > 1) `function* range(start, end) { for (const i = +start; i < end; ++i) { > yield i; } }` For future reference: `++i` throws when `i` is a `const` binding. The intended example uses `let` instead.

Re: Adding DOTALL modifier to ECMAScript regex standards

2016-08-15 Thread Mathias Bynens
> On 10 Aug 2016, at 16:02, Jake Reynolds wrote: > > I brought up the topic of adding the DOTALL modifier to the Chrome V8 Engine > here and was directed to es-discuss. I was curious about the practicality > and the want for adding a DOTALL modifier to the ECMAScript

Re: Adding DOTALL modifier to ECMAScript regex standards

2016-08-10 Thread Mathias Bynens
On Wed, Aug 10, 2016 at 4:40 PM, Bob Myers wrote: > If it's any consolation there is the more compact hack of `[^]`, which I > **think** is supposed to work everywhere. That doesn’t work in IE < 9, but that shouldn’t matter in 2016. ___

Re: Could we add the missing Regexp features from perl?

2016-06-24 Thread Mathias Bynens
> On 18 Jun 2016, at 00:01, Sebastian Zartner > wrote: > > There are already a few regexp features in the pipeline, see > https://github.com/goyakin/es-regexp (listed in the Stage 0 proposals at >

Re: Observing whether a function is strict

2016-05-26 Thread Mathias Bynens
On Thu, May 26, 2016 at 9:48 AM, Claude Pache wrote: > I was wondering whether there is a way to observe whether a given random > function is strict (or sloppy, or neither). > […] Are there other ways? (If not, I find it somewhat unfortunate that only > such nonstandard

Re: Object.getOwnPropertyDescriptors still at stage 0

2016-01-18 Thread Mathias Bynens
On Mon, Jan 18, 2016 at 6:50 PM, Andrea Giammarchi wrote: > Accordingly with this ecma262 stage 0 summary > https://github.com/tc39/ecma262/blob/master/stage0.md the (quite long time > ago) discussed `Object.getOwnPropertyDescriptors` >

Re: Object.getOwnPropertyDescriptors still at stage 0

2016-01-18 Thread Mathias Bynens
On Mon, Jan 18, 2016 at 8:27 PM, Andrea Giammarchi wrote: > Do you (or anyone else) know if that should be filed as a PR to tc39/ecma262 > or if it should just be a repository eventually posted in here? It should be a repository that can eventually move to the tc39

Re: RegExp.escape()

2015-06-30 Thread Mathias Bynens
On Mon, Jun 29, 2015 at 9:04 PM, Benjamin Gruenbaum benjami...@gmail.com wrote: Why? What advantage would it offer? See Scott’s previous email: On Mon, Jun 29, 2015 at 8:42 PM, C. Scott Ananian ecmascr...@cscott.net wrote: Imagine trying to ensure that any characters over \u007f were escaped.

Re: Parser for ES6?

2015-05-07 Thread Mathias Bynens
On Thu, May 7, 2015 at 5:37 PM, Park, Daejun dpar...@illinois.edu wrote: Is there any parser for ES6? https://github.com/shapesecurity/shift-parser-js supports ES6/ES2015 RC2. You can read more about it here: http://engineering.shapesecurity.com/2015/04/two-phase-parsing.html

Re: Declaration binding instationationing

2015-04-29 Thread Mathias Bynens
On Wed, Apr 29, 2015 at 7:29 AM, Garrett Smith dhtmlkitc...@gmail.com wrote: There is an English problem here: Let existingProp be the resulting of calling the [[GetProperty]] internal method of go with argument fn. s/resulting/result/ indeed. Can the spec be made easier to read? FYI, the

Re: Should const be favored over let?

2015-04-17 Thread Mathias Bynens
On Fri, Apr 17, 2015 at 7:53 AM, Glen Huang curvedm...@gmail.com wrote: I've completely replaced var with let in my es 2015 code, but I noticed most variables I introduced never change. Note that `const` has nothing to do with the value of a variable changing or not. It can still change:

Re: Number.prototype not being an instance breaks the web, too

2015-04-13 Thread Mathias Bynens
CCing Piotr. On Mon, Apr 13, 2015 at 5:37 PM, Mark S. Miller erig...@google.com wrote: Hold on. I may have reacted too quickly. If it is only jsfiddle, since this is an online service rather than a widely copied library, they could just fix it. OTOH, if it really is a mootools issue, then yes,

Re: Unicode normalization problem

2015-04-02 Thread Mathias Bynens
On Thu, Apr 2, 2015 at 1:39 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Jordan the purpose of `Array.from` is to iterate over the string, and the point of iteration instead of splitting is to have automagically codepoints. This, unless I've misunderstood Mathias presentation

Re: Unicode normalization problem

2015-04-01 Thread Mathias Bynens
On Wed, Apr 1, 2015 at 9:17 PM, Alexander Guinness monolit...@gmail.com wrote: My reasoning is based on the following example: ```js var text = '퐀'; text.length; // 2 Array.from(text).length // 1 ``` What you’re seeing there is not normalization, but rather the string iterator that

Re: Unicode normalization problem

2015-04-01 Thread Mathias Bynens
On Wed, Apr 1, 2015 at 10:30 PM, monolithed monolit...@gmail.com wrote: What you’re seeing there is not normalization, but rather the string iterator that automatically accounts for surrogate pairs (treating them as a single unit). ```js var foo = '퐀'; var bar = 'Й'; foo.length; // 2

Re: Should `use strict` be a valid strict pragma?

2015-02-05 Thread Mathias Bynens
On 5 Feb 2015, at 11:04, Leon Arnott leonarn...@gmail.com wrote: Well, that isn't quite the full story - if it were just a case of pragmas having to use something, anything, that could pass ES3 engines, then there wouldn't necessarily be two otherwise-redundant forms of the syntax - `use

Re: Q: Lonely surrogates and unicode regexps

2015-01-28 Thread Mathias Bynens
On 28 Jan 2015, at 11:36, Marja Hölttä ma...@chromium.org wrote: TL;DR: /foo.bar/u.test(“foo\uD83Dbar”) == ? The ES6 unicode regexp spec is not very clear regarding what should happen if the regexp or the matched string contains lonely surrogates (a lead surrogate without a trail, or a

Re: escaping - in /u RegExp

2015-01-14 Thread Mathias Bynens
On 13 Jan 2015, at 22:23, Allen Wirfs-Brock al...@wirfs-brock.com wrote: Would those of you who consider yourselves RegExp experts take a look at https://bugs.ecmascript.org/show_bug.cgi?id=3519 Is this a bug? If so, what is the fix? This construction for Identity Escape goes back to

Re: Sept 23 2014 Meeting Notes

2014-10-03 Thread Mathias Bynens
Thanks for once again putting this together, Rick! On Fri, Oct 3, 2014 at 3:22 PM, Rick Waldron waldron.r...@gmail.com wrote: ## 4.4 Number('0b0101'). NaN or not? (Erik Arvidsson) EA: Previous discussion:

Re: RegExps that don't modify global state?

2014-09-17 Thread Mathias Bynens
On Tue, Sep 16, 2014 at 8:16 PM, Domenic Denicola dome...@domenicdenicola.com wrote: I also noticed today that the static `RegExp` properties are not specced, which seems at odds with our new mandate to at least Annex B-ify the required-for-web-compat stuff. As a general note to people

Re: use strict VS setTimeout

2014-09-07 Thread Mathias Bynens
On Sun, Sep 7, 2014 at 7:29 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: This looks like a potential problem when possible passed methods are not bound + it looks inconsistent with *use strict* expectations. It’s not just `setTimeout` – other DOM timer methods have the same

Re: Questions regarding ES6 Unicode regular expressions

2014-08-26 Thread Mathias Bynens
reports welcome.) On Aug 25, 2014, at 1:59 , Mathias Bynens math...@qiwi.be wrote: Norbert’s original proposal for the `u` flag (http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/#RegExp) mentioned the following: Possibly the definition of the character classes `\d\D\w

Re: Questions regarding ES6 Unicode regular expressions

2014-08-26 Thread Mathias Bynens
On 26 Aug 2014, at 19:01, Allen Wirfs-Brock al...@wirfs-brock.com wrote: I've thought about this a bit. I was initially inclined to agree with the idea of extending the existing character classes similar to what Mathias' proposes. But I now think that is probably not a very good idea and

Questions regarding ES6 Unicode regular expressions

2014-08-25 Thread Mathias Bynens
Norbert’s original proposal for the `u` flag (http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/#RegExp) mentioned the following: Possibly the definition of the character classes `\d\D\w\W\b\B` is extended to their Unicode extensions, such as all characters in the

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-08 Thread Mathias Bynens
Claude Pache proposed the following spec patch: https://bugs.ecmascript.org/show_bug.cgi?id=2792#c11 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: July 29 2014 TC39 Meeting Notes

2014-08-06 Thread Mathias Bynens
On 5 Aug 2014, at 18:30, Rick Waldron waldron.r...@gmail.com wrote: - Spread now works on strings `var codeUnits = [...this is a string]` The code example implies it results in an array of strings, one item for each UCS-2/UTF-16 code unit. Shouldn’t this be symbols matching whole Unicode code

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-06 Thread Mathias Bynens
On 7 Aug 2014, at 02:46, Bill Frantz fra...@pwpconsult.com wrote: On Tue, Aug 5, 2014 at 7:56 AM, Mathias Bynens math...@qiwi.be wrote: ... In section 11.8.3 (Numeric Literals), the definition for `DecimalIntegerLiteral` should somehow be tweaked to match that of `DecimalDigits

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 02:41, Allen Wirfs-Brock al...@wirfs-brock.com wrote: there is already a bug open on this https://bugs.ecmascript.org/show_bug.cgi?id=2792 Older bug report: https://bugs.ecmascript.org/show_bug.cgi?id=1553 We previously discussed this up at the April TC39 meeting:

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 08:40, Mathias Bynens math...@qiwi.be wrote: On 5 Aug 2014, at 02:41, Allen Wirfs-Brock al...@wirfs-brock.com wrote: there is already a bug open on this https://bugs.ecmascript.org/show_bug.cgi?id=2792 Older bug report: https://bugs.ecmascript.org/show_bug.cgi?id=1553

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 4 Aug 2014, at 18:55, Jason Orendorff jason.orendo...@gmail.com wrote: We're talking about something different here, legacy *decimal* integer literals starting with 0 and containing 8 or 9. As far as I know, no version of ES has ever permitted this kind of nonsense, but supporting it is

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 16:20, Allen Wirfs-Brock al...@wirfs-brock.com wrote: We're only talking about Annex B, non-strict. Right? All engines are going to implement this anyway, so why make it Annex B only? I wouldn’t restrict it to non-strict mode either, as this decision seems to be purely

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 16:56, Alex Kocharin a...@kocharin.ru wrote: What about allowing one-digit numbers with leading zeroes? 07 equals to 7 no matter whether it parsed as an octal or as a decimal. Thus, no harm there. That wouldn’t solve the problem. Consider e.g. `01234567` (i.e. `342391`) vs.

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 17:05, Mark S. Miller erig...@google.com wrote: Because of compatibility constraints, JS history can generally proceed only in an additive manner, which means a steady degradation of quality along the simplicity dimension. An opt-in mode switch is the only way to escape

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 17:05, Mark S. Miller erig...@google.com wrote: Strict mode should not accept octal literals. The literals under discussion (e.g. `08` and `09`) are not octal literals. ___ es-discuss mailing list es-discuss@mozilla.org

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Mathias Bynens
On 5 Aug 2014, at 17:19, Mark S. Miller erig...@google.com wrote: On Tue, Aug 5, 2014 at 8:17 AM, Mathias Bynens math...@qiwi.be wrote: The literals under discussion (e.g. `08` and `09`) are not octal literals. Strict mode should reject these even more vehemently! (Allen, can we have

Re: [Strawman proposal] StrictMath variant of Math

2014-08-01 Thread Mathias Bynens
On 1 Aug 2014, at 09:25, Carl Shapiro carl.shap...@gmail.com wrote: Thanks for the suggestion. As Ray pointed out, the Math package in Java still has its accuracy requirements specified and so it is not analogous to the current status of Math package in ES6. Also, the StrictMath package

Re: 5 June 2014 TC39 Meeting Notes

2014-06-14 Thread Mathias Bynens
On 13 Jun 2014, at 18:15, Domenic Denicola dome...@domenicdenicola.com wrote: IMO it would be a good universe where `module` had the following things `script` has: - Does not require escaping' in any contexts. - Terminates when seeing `/module` + extra chars. (Possibly we could do

Re: Idea for ECMAScript 7: Number.compare(a, b)

2014-06-06 Thread Mathias Bynens
On 6 Jun 2014, at 01:15, Axel Rauschmayer a...@rauschma.de wrote: It’d be nice to have a built-in way for comparing numbers, e.g. when sorting arrays. ```js // Compact ECMAScript 6 solution // Risk: number overflow [1, 5, 3, 12, 2].sort((a,b) = a-b) // Proposed new function: [1, 5,

Re: Array.prototype.last()

2014-05-14 Thread Mathias Bynens
Previous discussion on this topic: http://esdiscuss.org/topic/array-prototype-last We should look at how existing utility libraries handle this behavior and base any proposals on that IMHO. Underscore and Lo-Dash have [`_.first`](http://lodash.com/docs#first) and

Re: Native base64 utility methods

2014-05-08 Thread Mathias Bynens
On 5 May 2014, at 20:22, Andrea Giammarchi andrea.giammar...@gmail.com wrote: @mathias didn't mean to change atob and btoa rather add two extra methods such encode/decode for strings (could land without problems in the String.prototype, IMO) with less silly names whatever definition of silly

Re: ToPropertyDescriptor, [[HasProperty]], [[HasOwnProperty]]

2014-05-08 Thread Mathias Bynens
On Fri, May 9, 2014 at 1:44 AM, John-David Dalton john.david.dal...@gmail.com wrote: Should I create a spec bug for tracking this? Please do. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Native base64 utility methods

2014-05-05 Thread Mathias Bynens
On 5 May 2014, at 00:00, Andrea Giammarchi andrea.giammar...@gmail.com wrote: as generic global utility it would be also nice to make it compatible with all strings. For backwards compatibility reasons, `atob`/`btoa` should probably continue to work in exactly the same way they work now (i.e

Re: Native base64 utility methods

2014-05-05 Thread Mathias Bynens
On 5 May 2014, at 10:48, Claude Pache claude.pa...@gmail.com wrote: In my view, if `atob` and `btoa` were to enter in ES, it should be in Appendix B (the deprecated legacy features of web browsers), where it would be in good company with the other utility that does an implicit confusion

Native base64 utility methods

2014-05-04 Thread Mathias Bynens
To convert from base64 to ASCII and vice versa, browsers have had global `atob` and `btoa` functions for a while now. At the moment, these are defined in the HTML standard: http://whatwg.org/html/webappapis.html#atob However, such utility methods are not only useful in browsers. How about

Re: RegExp.escape

2014-03-21 Thread Mathias Bynens
On 21 Mar 2014, at 16:38, C. Scott Ananian ecmascr...@cscott.net wrote: ```js function replaceTitle(title, str) { return str.replace(new RegExp(title), ...); } ``` There ought to be a standard simple way of writing this correctly. I’ve used something like this in the past:

Re: Array.prototype.contains

2014-03-05 Thread Mathias Bynens
On 5 Mar 2014, at 17:19, Domenic Denicola dome...@domenicdenicola.com wrote: Personally I think the more useful model to follow than `String.prototype.contains` is `Set.prototype.has`. But then DOM4 `DOMStringList` would still have its own `contains` _and_ the `has` it inherits from

Re: Another switch

2014-02-20 Thread Mathias Bynens
On 20 Feb 2014, at 21:20, Eric Elliott e...@ericleads.com wrote: Object literals are already a great alternative to switch in JS: var cases = { val1: function () {}, val2: function () {} }; cases[val](); In that case, you’d need a `hasOwnProperty` check to make sure you’re not

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2014-02-15 Thread Mathias Bynens
On 14 Feb 2014, at 19:59, Allen Wirfs-Brock al...@wirfs-brock.com wrote: It's a really high bar to get over that closed gate. Unless the exclusion of a feature was a mistake […] I don't think we should be talking about adding it to ES6. It does feel like a mistake to me to introduce

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2014-02-14 Thread Mathias Bynens
Allen mentioned that `String#at` might not make it to ES6 because nobody in TC39 is championing it. I’ve now asked Rick if he would be the champion for this, and he agreed. (Thanks again!) Looking over the ‘TC39 progress’ document at

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2014-02-14 Thread Mathias Bynens
On 14 Feb 2014, at 11:11, Domenic Denicola dome...@domenicdenicola.com wrote: This was the method that was only useful if you pass `0` to it? I’ll just avoid the infinite loop here by pointing to earlier posts in this thread where this was discussed before:

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2014-02-14 Thread Mathias Bynens
On 14 Feb 2014, at 11:14, C. Scott Ananian ecmascr...@cscott.net wrote: Note that `Array.from(str)` and `str[Symbol.iterator]` overlap significantly. In particular, it's somewhat awkward to iterate over code points using `String#symbolAt`; it's much easier to use `substr()` and then use the

Re: comment overflow

2014-02-10 Thread Mathias Bynens
On 10 Feb 2014, at 10:30, Michael Dyck jmd...@ibiblio.org wrote: On a more meta level, do the process plans for ES7 include any new mechanisms for: (a) submitting comments on spec drafts, or (b) reducing the number of errors in spec drafts to begin with? If only the spec were maintained in a

Re: Ecmascript.org

2014-01-31 Thread Mathias Bynens
I was wondering who was in charge of the ecmascript.org web site. $ whois ecmascript.org [snip] Registrant Organization:Mozilla Corporation Registrant Street: 650 Castro St Ste 300 Registrant City:Mountain View Registrant State/Province:CA Registrant Postal Code:94041 Registrant Country:US

Re: `String.prototype.contains(regex)`

2013-12-23 Thread Mathias Bynens
On 18 Dec 2013, at 23:02, Benjamin (Inglor) Gruenbaum ing...@gmail.com wrote: If anything, I'd expect all of them to throw when passed multiple arguments for forward compatibility. It might be useful to check multiple values in contains/endsWith/startsWith or constrain it in some way. The

`String.prototype.contains(regex)`

2013-12-18 Thread Mathias Bynens
Both `String.prototype.startsWith` and `String.prototype.endsWith` throw a `TypeError` if the first argument is a RegExp: Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extends that allow such argument values. However, this is

Function.prototype.apply() Function.prototype.call() with `undefined` or `null` as `thisArg`

2013-12-10 Thread Mathias Bynens
From http://ecma-international.org/ecma-262/5.1/#sec-15.3.4.3 and http://ecma-international.org/ecma-262/5.1/#sec-15.3.4.4: The `thisArg` value is passed without modification as the `this` value. This is a change from Edition 3, where a `undefined` or `null` `thisArg` is replaced with the

Re: Function.prototype.apply() Function.prototype.call() with `undefined` or `null` as `thisArg`

2013-12-10 Thread Mathias Bynens
Turns out this is a bug in the spec: https://bugs.ecmascript.org/show_bug.cgi?id=2370 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Using Unicode code point escape sequences in regular expressions without the `u` flag

2013-11-22 Thread Mathias Bynens
One more related question: are these three regular expression literals equivalent? 1. `/[-]/u`: raw astral symbols 2. `/[\u{1F4A9}-\u{1F4AB}]/u`: astral symbols represented using Unicode code point escape sequences 3. `/[\uD83D\uDCA9-\uD83D\uDCAB]/u`: astral symbols represented as a surrogate

Re: Using Unicode code point escape sequences in regular expressions without the `u` flag

2013-11-22 Thread Mathias Bynens
On 22 Nov 2013, at 11:20, Allen Wirfs-Brock al...@wirfs-brock.com wrote: Did you check the ES6 draft grammar{1]? The answer to that should be fairly obvious there and if it isn't it would be good to know so we can try to make it clearer in the spec. [1]:

Using Unicode code point escape sequences in regular expressions without the `u` flag

2013-11-21 Thread Mathias Bynens
If I’m reading the latest draft correctly, `RegExpUnicodeEscapeSequence`s aren’t allowed in regular expressions without the `u` flag. Why is that? AFAICT, the only situations that require looking at code points rather than UCS-2/UTF-16 code units in order to support full Unicode are: * the

Re: [Json] BOMs

2013-11-21 Thread Mathias Bynens
On 21 Nov 2013, at 09:41, Bjoern Hoehrmann derhoe...@gmx.net wrote: Is there any chance, by the way, to change `JSON.stringify` so it does not output strings that cannot be encoded using UTF-8? Specifically, JSON.stringify(JSON.parse(\\uD800\)) would need to escape the surrogate instead

Re: Working with grapheme clusters

2013-10-27 Thread Mathias Bynens
On 26 Oct 2013, at 14:39, Bjoern Hoehrmann derhoe...@gmx.net wrote: * Norbert Lindenberg wrote: On Oct 25, 2013, at 18:35 , Jason Orendorff jason.orendo...@gmail.com wrote: UTF-16 is designed so that you can search based on code units alone, without computing boundaries. RegExp searches

Re: Working with grapheme clusters

2013-10-24 Thread Mathias Bynens
On 24 Oct 2013, at 16:02, Claude Pache claude.pa...@gmail.com wrote: Therefore, I propose the following basic operations to operate on grapheme clusters: Out of curiosity, is there any programming language that operates on grapheme clusters (rather than code points) by default? FWIW, code

Re: Working with grapheme clusters

2013-10-24 Thread Mathias Bynens
On 24 Oct 2013, at 16:22, Anne van Kesteren ann...@annevk.nl wrote: On Thu, Oct 24, 2013 at 3:02 PM, Claude Pache claude.pa...@gmail.com wrote: As a side note, I ask whether the `String.prototype.symbolAt `/`String.prototype.at` as proposed in a recent thread, and the

Re: Making the identifier identification strawman less restrictive

2013-10-22 Thread Mathias Bynens
On 14 Oct 2013, at 23:21, Erik Arvidsson erik.arvids...@gmail.com wrote: I'm concerned about the latest version of this on the wiki. The edition parameter requires that we ship 2 tables today. This seems like it might change to 3 in ES7 and n in ES(n+4). I think the only reasonable

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-20 Thread Mathias Bynens
On 19 Oct 2013, at 12:54, Domenic Denicola dome...@domenicdenicola.com wrote: My proposed cowpaths: ```js Object.mixin(String.prototype, { realCharacterAt(i) { let index = 0; for (var c of this) { if (index++ === i) { return c; } } } get realLength() {

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-19 Thread Mathias Bynens
On 19 Oct 2013, at 12:15, Bjoern Hoehrmann derhoe...@gmx.net wrote: Certainly not common enough to warrant a two-character method on the native string type. Odds are people will use it incorrectly in an attempt to make their code look concise […] Are you saying that changing the name to

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-19 Thread Mathias Bynens
On 19 Oct 2013, at 00:53, Domenic Denicola dome...@domenicdenicola.com wrote: On 19 Oct 2013, at 01:12, Mathias Bynens math...@qiwi.be wrote: `String.prototype.codePointAt` or `String.prototype.at` come in handy in case you only need to get the first code point or symbol in a string

`String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
ES6 fixes `String.fromCharCode` by introducing `String.fromCodePoint`. Similarly, `String.prototype.charCodeAt` is fixed by `String.prototype.codePointAt`. Should there be a method that is like `String.prototype.charAt` except it deals with astral Unicode symbols wherever possible?

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
On 18 Oct 2013, at 09:21, Rick Waldron waldron.r...@gmail.com wrote: I think the idea is good, but the name may be confusing with regard to Symbols (maybe not?) Yeah, I thought about that, but couldn’t figure out a better name. “Glyph” or “Grapheme” wouldn’t be accurate. Any suggestions?

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
Here’s my proposal. Feedback welcome, as well as suggestions for a better name (if any). ## String.prototype.symbolAt(pos) NOTE: Returns a single-element String containing the code point at element position `pos` in the String `value` resulting from converting the `this` object to a String.

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
On 18 Oct 2013, at 10:48, Anne van Kesteren ann...@annevk.nl wrote: On Fri, Oct 18, 2013 at 1:46 PM, Mathias Bynens math...@qiwi.be wrote: Similarly, `String.prototype.charCodeAt` is fixed by `String.prototype.codePointAt`. When you phrase it like that, I see another problem

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
On 18 Oct 2013, at 11:05, Anne van Kesteren ann...@annevk.nl wrote: On Fri, Oct 18, 2013 at 4:58 PM, Mathias Bynens math...@qiwi.be wrote: I disagree. In those situations you should just iterate over the string using `for…of`. That seems to iterate over code units as far as I can tell

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
Please ignore my previous email; it has been answered already. (It was a draft I wrote up this morning before I lost my internet connection.) On 18 Oct 2013, at 11:57, Allen Wirfs-Brock al...@wirfs-brock.com wrote: Given that we have charAt, charCodeAt and codePointAt, I think the most

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
On 18 Oct 2013, at 15:12, Andrea Giammarchi andrea.giammar...@gmail.com wrote: so my counter-question would be: is there any way to do that in core so that we can “”.split() it so that we can have an ArrayLike that with [1] gives back the single “” and not the whole thing ? This brings

Re: `String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

2013-10-18 Thread Mathias Bynens
On 18 Oct 2013, at 17:51, Joshua Bell jsb...@google.com wrote: Given that you can only use the proposed String.prototype.at() properly for indexes 0 if you know the index of a non-BMP character or lead surrogate by some other means, or if you will test the return value for a trailing

Re: How is let compatibility resolved?

2013-10-14 Thread Mathias Bynens
On 2 Oct 2013, at 10:45, Petka Antonov petka_anto...@hotmail.com wrote: In current version, this works just fine: var let = 6; Note that `let` was reserved in strict mode (only) in ES5, meaning that even as per ES5 that snippet only works in sloppy mode.

Fwd: Making the identifier identification strawman less restrictive

2013-10-11 Thread Mathias Bynens
...@lindenbergsoftware.com Cc: Mathias Bynens math...@qiwi.be, es-discuss es-discuss@mozilla.org, Anton Kovalyov an...@kovalyov.net, Yusuke SUZUKI utatane@gmail.com, ariya.hida...@gmail.com, Jeremy Ashkenas jashke...@gmail.com, mi...@bazon.net I have no particular opinion about this. Identifiers

Fwd: Making the identifier identification strawman less restrictive

2013-10-10 Thread Mathias Bynens
Forwarding Anton’s message since he’s not subscribed to es-discuss. Begin forwarded message: From: Anton Kovalyov an...@kovalyov.net Subject: Re: Making the identifier identification strawman less restrictive Date: 9 October 2013 22:17:50 CEST To: Mathias Bynens math...@qiwi.be Cc: Norbert

Re: Making the identifier identification strawman less restrictive

2013-10-09 Thread Mathias Bynens
CC’ing the creators of the tools we’ve been talking about to get their input. Hi guys! Please start reading here: http://esdiscuss.org/topic/making-the-identifier-identification-strawman-less-restrictive. On 9 Oct 2013, at 07:48, Norbert Lindenberg ecmascr...@lindenbergsoftware.com wrote: -

Re: FYI: Ecma-404 approved and published

2013-10-08 Thread Mathias Bynens
On 8 Oct 2013, at 19:59, Allen Wirfs-Brock al...@wirfs-brock.com wrote: The Ecma General Assembly has approved by letter ballot Ecma-404: THE JSON Data Interchange Formal See http://www.ecma-international.org/publications/standards/Ecma-404.htm As for Unicode, it explicitly refers to Unicode

Re: FYI: Ecma-404 approved and published

2013-10-08 Thread Mathias Bynens
On 8 Oct 2013, at 22:19, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Oct 8, 2013 at 4:10 PM, Mathias Bynens math...@qiwi.be wrote: As for Unicode, it explicitly refers to Unicode 6.2.0, even though version 6.3.0 was released last week. The document was written in July, which

Re: FYI: Ecma-404 approved and published

2013-10-08 Thread Mathias Bynens
On 8 Oct 2013, at 23:39, Mark S. Miller erig...@google.com wrote: JSON must not change. If it refers to the latest Unicode, whatever that is, then it is potentially subject to disruption by (admittedly unlikely) future changes to Unicode. By that logic, it should have referred to either

Making the identifier identification strawman less restrictive

2013-10-06 Thread Mathias Bynens
This is about the identifier identification strawman: http://wiki.ecmascript.org/doku.php?id=strawman:identifier_identification For tooling, it’s better to have a false positive than to have a false negative. In the case of identifier identification, it’s more useful to flag an identifier that

On `String.prototype.codePointAt` and `String.fromCodePoint`

2013-09-24 Thread Mathias Bynens
Patches implementing `String.prototype.codePointAt` and `String.fromCodePoint` are available for both SpiderMonkey (https://bugzilla.mozilla.org/show_bug.cgi?id=918879) and V8 (https://code.google.com/p/v8/issues/detail?id=2840). One spec bug remains to be fixed, though:

Re: On `String.prototype.codePointAt` and `String.fromCodePoint`

2013-09-24 Thread Mathias Bynens
I think I'm convinced that String.fromCodePoint()'s design is correct, especially since the rendering subsystem deals with code points too. Glad to hear. String.prototype.codePointAt() however still feels wrong since you always need to iterate from the start to get the correct code *unit*

Re: Backwards compatibility and U+2E2F in `Identifier`s

2013-09-18 Thread Mathias Bynens
On 18 Sep 2013, at 21:05, Anne van Kesteren ann...@annevk.nl wrote: On Mon, Aug 19, 2013 at 5:25 AM, Mathias Bynens math...@qiwi.be wrote: After comparing the output, I noticed that both regular expressions are identical except for the following: ECMAScript 5 allows U+2E2F VERTICAL TILDE

Re: Code points vs Unicode scalar values

2013-09-11 Thread Mathias Bynens
On 10 Sep 2013, at 18:30, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Sep 10, 2013, at 12:14 AM, Mathias Bynens wrote: FWIW, here’s a real-world example of a case where this behavior is annoying/unexpected to developers: http://cirw.in/blog/node-unicode This suggests to me

Re: Code points vs Unicode scalar values

2013-09-10 Thread Mathias Bynens
FWIW, here’s a real-world example of a case where this behavior is annoying/unexpected to developers: http://cirw.in/blog/node-unicode ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Question about allowed characters in identifier names

2013-09-05 Thread Mathias Bynens
On 26 Aug 2013, at 04:08, Norbert Lindenberg ecmascr...@lindenbergsoftware.com wrote: On Aug 24, 2013, at 23:43 , Mathias Bynens math...@qiwi.be wrote: I would suggest adding something like `String.isIdentifier` which accepts a multi-symbol string or an array of code points

Re: Code points vs Unicode scalar values

2013-09-04 Thread Mathias Bynens
On 4 Sep 2013, at 18:34, Brendan Eich bren...@mozilla.com wrote: Here, from the latest ES6 draft, is 15.5.2.3 String.fromCodePoint ( ...codePoints): The String.fromCodePoint function may be called with a variable number of arguments which form the rest parameter codePoints. The

Re: Question about allowed characters in identifier names

2013-08-25 Thread Mathias Bynens
On 25 Aug 2013, at 04:17, Norbert Lindenberg ecmascr...@lindenbergsoftware.com wrote: I don't think that's a technical problem. String.isIdentifier{Start,Part}, as I proposed them, don't deal with actual identifiers in source text; they check individual identifier characters. The

Re: Question about allowed characters in identifier names

2013-08-24 Thread Mathias Bynens
On 27 Feb 2012, at 22:58, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Feb 26, 2012, at 1:55 AM, Mathias Bynens wrote: For example, U+2F800 CJK COMPATIBILITY IDEOGRAPH-2F800 is a supplementary Unicode character in the [Lo] category, which leads me to believe it should be allowed

  1   2   >