It's been pretty quiet around here since we debated tail calls...  A
thread on nomenclature sounds like it could get good.

Triple-quoted string parsing does not stop at the first possible end
delimiter; it stops at the first end delimiter where local inspection
of the string around the potential termination point makes it possible
to conclude that the string probably was not intended to extend
further.  That is what Comen, Leiserson, and Rivest[*] call greedy in
their discussion of greedy algorithms: "A //greedy algorithm// always
makes the choice that looks best at the moment.  That is, it makes a
locally optimal choice in the hope that this choice will lead to a
globally optimal solution."

Knuth does not include the term in his index, sadly, nor do any of my
other algorithm books.  Can somebody dig up a conflicting definition
so that we can get a real discussion going?

--lars

[*] 1st edition

On Feb 18, 2008 7:22 PM, P T Withington <[EMAIL PROTECTED]> wrote:
> Since your more precise definition effectively says the string stops
> at the first possible end delimiter, I agree with the other commenters
> that that is not what I would call greedy.
>
>
> On Feb 18, 2008, at 5:08, "Lars T Hansen" <[EMAIL PROTECTED]> 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.)
> >
> > --lars
> >
> > On Feb 18, 2008 10:56 AM, Dominic Cooney <[EMAIL PROTECTED]>
> > 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@mozilla.org
> >> https://mail.mozilla.org/listinfo/es4-discuss
> >>
> > _______________________________________________
> > Es4-discuss mailing list
> > Es4-discuss@mozilla.org
> > https://mail.mozilla.org/listinfo/es4-discuss
>
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to