Greedy triple-quoted string literals

Lars T Hansen lth at acm.org
Mon Feb 18 02:08:33 PST 2008


The correct interpretation is that a triple quoted string starts with
three quotes of the same kind and ends when the same three quotes are
seen in sequence provided that the character following the three is
not that same quote character.

(Whether you want to call that greedy or not depends on whether you
think it's greedy to take what you can when you can take it, or
whether you think it's greedy to avoid taking something now because
you think you can take more later.  Generally speaking a greedy
algorithm is one that makes a locally optimal choice about what is
best, so I think the description on the wiki is OK.  The above
description is more precise.)

--lars

On Feb 18, 2008 10:56 AM, Dominic Cooney <dominic.cooney at gmail.com> wrote:
> There's a note on the triple-quoted string literals proposal*:
>
> "we decided that triple-quoted strings would be greedy when looking
> for the closing triple-quotes."
>
> Wouldn't this mean, in practice, that it is only possible to have two
> triple-quoted string literals per source file (one with """ and
> another with ''')?
>
> * http://wiki.ecmascript.org/doku.php?id=proposals:triple_quotes
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
>



More information about the Es4-discuss mailing list