ES4 draft: Triply quoted string literals

Michael Daumling mdaeumli at adobe.com
Wed Mar 5 00:16:46 PST 2008


 
Waldemar Horwat wrote:
>>> I'm not sure what the intent is, but as this is written:
>>>
>>> """abc""""def"""
>>>
>>> will evaluate to the same string as 'abc""""def'.
>> 
>> It will not.  The text of the spec is "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."  So the string is the four-letter sequence abc".
>> Perhaps the sentence would be even clearer if the word "immediately" 
>> were to precede the word "followed".

>>From the discussions on the list I knew what you meant, but as written
>>this is ambiguous.  I read it as a string of four or more quote 
>>characters not being eligible to be a terminator, so you skip it 
>>and look for the next sequence.

With the same argumentation, you could argue that the next triple quote
sequence is nothing but a double quote, followed by a single quote.
Writing a lexer that recognizes a triple quoted string like yours above
in the way you described could quickly become very complicated - never
to mention the human mind, who would struggle to recognize a proper
string termination in such source code as well.

I strongly favor Lars' point of view, where above string should be
considered a syntax error.

Michael



More information about the Es4-discuss mailing list