Suggestions to triple quoted strings proposal

Bob Ippolito bob at redivi.com
Wed Dec 13 09:32:39 PST 2006


On 12/14/06, P T Withington <ptw at pobox.com> wrote:
> On 2006-12-13, at 10:13 EST, Dave Herman wrote:
>
> >> It doesn't seem particularly arduous to do:
> >> function query() {
> >>   return
> >>   """SELECT 15
> >>   FROM dual
> >>   """
> >> }
> >
> > I haven't been following this thread closely, but the above will
> > not parse; you aren't allowed to move the argument to a return to
> > the next line. The parser will parse that as a return with no
> > arguments.
>
> One of the biggest traps of implicit `;`s.  Bitten me too many
> times!  But you _could_ say:
>
> function query() {
>    return (
> """SELECT 15
> FROM dual
> """)
> }
>
> Since I'm here, I'll just toss out the Dylan way, which is to have
> adjacent strings concatenate:
>
> function query() {
>    return (
>     "SELECT 15"
>     " FROM dual"
>    )
> }

In many cases you probably want to preserve the newlines though, where
adjacent string concatenation makes it look like this:

return (
    "while True:\n"
    "    pass\n"
    );

-bob



More information about the Es4-discuss mailing list