ES4 draft: Triply quoted string literals

Waldemar Horwat waldemar at google.com
Mon Mar 3 17:24:35 PST 2008


I'm not sure what the intent is, but as this is written:

"""abc""""def"""

will evaluate to the same string as 'abc""""def'.

Furthermore,

"""\"""

turns into:

\

to which we're then supposed to apply escape processing, but that is not possible because there is no character following the backslash.  What happens?

What does the following evaluate to?

"""\n\\\"\t"""

Is it the same as "\n\\\"\t"?

If so, then triple quoting seems like an extraneous feature, as we still need to go through and double every backslash located inside the string.

    Waldemar


Lars Hansen wrote:
> Please comment.  --lars
> 
> 
> ------------------------------------------------------------------------
> 
> NAME:        "Triply quoted string literals"
> CATEGORY:    Lexical conventions (E262-3 ch 7)
> SOURCES:     References [1], [4]
> SPEC AUTHOR: Lars
> STATUS:      OPEN ISSUES
> REVIEWS:     (none)
> IMPLEMENTED: RI; Tamarin+ESC
> 
> 
> DESCRIPTION
> 
> A sequence of three unescaped SINGLEQUOTE or three unescaped
> DOUBLEQUOTE characters signifies the start of a triply-quoted string
> literal.  The literal is terminated by the earliest sequence of three
> unescaped instances of the the same quote character that is not
> followed by a fourth quote character of the same kind.
> 
> Arbitrary characters, including line terminator characters, are
> allowed between the starting and ending quotes.  Following
> determination of the starting and ending quotes the input text between
> the starting and ending quotes is subject to escape character
> processing, wherein sequences of characters starting with BACKSLASH
> are replaced by those single characters signified by the sequences.
> 
> The escape character processing is performed exactly as for singly
> quoted strings.
> 
> 
> NOTES
> 
> As always, line terminator normalization [2] is in effect.
> 
> 
> OPEN ISSUES
> 
> There is a note on the wiki [4] regarding whether \<lineterminator>
> should be handled differently in triple-quoted strings than in
> double-quoted strings.  Brendan's opinion is it should -- it should
> escape the <lineterminator>.  The RI does not implement that behavior,
> and the present proposal follows the RI.  See [3] for a more general
> discussion.
> 
> 
> DEFINITIONS
> 
> BACKSLASH=U+005C
> SINGLEQUOTE=U+0027
> DOUBLEQUOTE=U+0022
> 
> 
> REFERENCES
> 
> [1] http://wiki.ecmascript.org/doku.php?id=proposals:triple_quotes
> [2] "Line terminator normalization" spec
> [3] "Line continuation in string literals" spec
> [4] http://wiki.ecmascript.org/doku.php?id=proposals:line_terminator_normalization



More information about the Es4-discuss mailing list