Pedantry alert: someone noticed that JSON does not treat U+2028 and
U+2029 (line terminators in JS) as space characters. So these can occur
(unescaped) in JSON string literals, but not in JS string literals.
Therefore JSON accepts sentences not legal in JS:
js> JSON.parse('{"a":"\u2028","b":2}')
({a:"\u2028", b:2})
js> eval('({"a":"\u2028","b":2})')
typein:11: SyntaxError: unterminated string literal:
typein:11: ({"a":"(
typein:11: ......^
Does YAML treat U+2028 and U+2029 the same as JSON does, or as JS does?
/be
Russell Leggett wrote:
Not to keep being down on this post, but as long as YAML adds JS style
comments, wouldn't JSON still be a strict subset?
On Wed, Aug 8, 2012 at 12:57 PM, Jussi Kalliokoski
<[email protected] <mailto:[email protected]>> wrote:
And even if it wasn't, it wouldn't make much sense to use the only
punctuation symbol we have left for comments where we already have
two syntaxes. :)
Cheers,
Jussi
On Wed, Aug 8, 2012 at 7:38 PM, Rick Waldron
<[email protected] <mailto:[email protected]>> wrote:
On Wed, Aug 8, 2012 at 11:58 AM, Trans <[email protected]
<mailto:[email protected]>> wrote:
Hi. First time posting to the list, so please forgive if I
am not
following proper approach.
I'd like to make one proposal for future of EMCAScript. I
would like
to see support for `#` comment notation.
The # is already on hold for several potential syntax additions:
- sealed object initializers
http://wiki.ecmascript.org/doku.php?id=strawman:obj_initialiser_methods
- Tuples http://wiki.ecmascript.org/doku.php?id=strawman:tuples
- Records http://wiki.ecmascript.org/doku.php?id=strawman:records
Rick
The reasons for this are more interesting than one might
think.
First, of course, is the simple fact that `#` is a very common
notation among programming languages. It is used by Shell
scripts,
Ruby, Python, even Coffeescript, and many others.
Secondly, `#` is preferable to `//` in that it is only one
character
instead of two, and albeit subjective (IMHO) it just seems
a little
bit more aesthetic.
But another reason, that few will at first consider, is the
relationship between JSON and YAML. Their respective
development teams
made an effort to ensure JSON was a perfect subset of
YAML. Now there
is consideration of JSON5
(https://github.com/aseemk/json5). JSON5
adds support for comments, however it is Javascript style
comments,
where as YAML supports `#` style comments. This causes the
superset-subset relationship to break. To help remedy this
going
forward, it would be very helpful if EMCAScript also
supported `#`
comments. The YAML spec could in turn add support for `//`
style
comments.
To be clear, I am not suggesting that `//` be deprecated.
That would
simply break far too much old code for no good reason! I
am just
seeking for `#` to be supported too.
Thanks for consideration,
trans
_______________________________________________
es-discuss mailing list
[email protected] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss