Greedy triple-quoted string literals

Lars Hansen lhansen at
Mon Feb 18 04:33:22 PST 2008

> -----Original Message-----
> From: es4-discuss-bounces at 
> [mailto:es4-discuss-bounces at] On Behalf Of liorean
> Sent: 18. februar 2008 11:53
> To: es4-discuss at
> Subject: Re: Greedy triple-quoted string literals
> On 18/02/2008, Lars T Hansen <lth at> wrote:
> > 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.)
> I think that's a confusion waiting to happen that I certainly 
> wouldn't want to see in spec text. The concept of "greedy" 
> matching that I have would mean that the last triple quote 
> delimiter in the source would be considered to be the 
> endpoint of the literal that started with the first triple 
> quote delimiter in the source.

The spec will be more precise than the wiki proposals in all cases, and
will necessarily avoid these kinds of terms (except when it defines the
terms precisely first).  I hope the interpretation that I gave above is
sufficiently clear for a spec.  It would be possible to provide an
operational definition instead, but I hope we can avoid that for the
surface syntax.


More information about the Es4-discuss mailing list