Suggestions to triple quoted strings proposal

Stepan Koltsov stepan.koltsov at gmail.com
Tue Dec 12 11:24:12 PST 2006


Hi,

I've read proposal of triple quoted strings at

http://developer.mozilla.org/es4/proposals/triple_quotes.html

And I have two suggestions. I've sent them to Brendian Eich, and he
redirected me to this mailing list.

I suggest to change interpretation of triple quoted string.

First,

I suggest to ignore first character of string if it is newline. So statement

messageTemplate = """
Hello,
I've just...
"""

should be equivalent to

messageTemplate = "Hello,\nI've just...\n"

, but not

messageTemplate = "\nHello,\nI've just...\n".

And second: to ignore same number of spaces as number of spaces in
the line where triple quoted string started. Example:

function query() {
    return """
    SELECT * FROM people
    WHERE date_created > ? AND disabled = 'N'
    """
}

should be equivalent to

function query() {
    return "SELECT * FROM people\nWHERE date_created > ? AND disabled = 'N'\n";
}

but not as now:

function query() {
    return "    SELECT * FROM people\n    WHERE date_created > ? AND
disabled = 'N'\n";
}

I think that these improvements would make triple quoted string more
useful and easier. Hope, these suggestions will be added to proposal.

--
Stepan Koltsov



More information about the Es4-discuss mailing list