Please comment.  --lars
NAME:        "Line continuation in string literals"
CATEGORY:    Lexical conventions (E262-3 ch 7)
SOURCES:     References [1], [2]
SPEC AUTHOR: Lars
STATUS:      OPEN ISSUES
REVIEWS:     (none)
IMPLEMENTED: RI (partial); Tamarin+ESC


DESCRIPTION

The character sequence BACKSLASH <lineterminator> (where
<lineterminator> will be one of the characters LF, LS, or PS) is
removed from strings delimited by either single or triple SINGLEQUOTE
or DOUBLEQUOTE characters.  (Triple-quoting is defined in [5].)


NOTES

It is assumed that line terminator normalization [4] is in effect,
thus CR does not appear in string literals.


OPEN ISSUES

(1) Should line continuations be handled in triply quoted strings?
The wiki says no, the RI says yes.  I've gone with the RI because the
"optimization" described in the wiki [2] is probably going to be
counterintuitive to most users and of effectively no value.  See
longer discussion below.

(2) The RI does not handle BACKSLASH LS or BACKSLASH PS, but [1] seems
to indicate that it's the intent to handle them (it references the
LineTerminator nonterminal, which includes these characters), so I've
gone with the wiki.


DISCUSSION

This feature comes from the bug fix [BACKSLASH.NEWLINE.IN.STRING] in
[1], applying to strings only (not regular expression literals,
identifiers, or block comments, nor generally as a transformation that
would take place before tokenization).

Its application to triply quoted strings [3] was discussed in [2],
where it was proposed that there would be no removal of BACKSLASH
<lineterminator> in those strings, but that the sequence would just
turn into the literal <lineterminator> character, like other white
space.  The argument was that since removal was not needed in those
strings then it was also not wanted.

The RI scanner actually removes BACKSLASH <lineterminator> in triply
quoted strings.  I believe this is probably the desired behavior,
which is why it has been specified above.

Note that it is probably not necessary to have line continuations in
regexp literals because the new scanning rules for ES4 allows
linebreaks with the "x" flag.  The absence of support is however a
little jarring IMO.


DEFINITIONS

LF=U+000A
CR=U+000D
BACKSLASH=U+005C
LS=U+2028
PS=U+2029
SINGLEQUOTE=U+0027
DOUBLEQUOTE=U+0022


REFERENCES

[1] http://wiki.ecmascript.org/doku.php?id=proposals:bug_fixes
[2] 
http://wiki.ecmascript.org/doku.php?id=proposals:line_terminator_normalization
[3] http://wiki.ecmascript.org/doku.php?id=proposals:triple_quotes
[4] "Line terminator normalization" spec
[5] "Triply quoted string literals" spec
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to