Suggestions to triple quoted strings proposal

Jeff Walden jwalden at MIT.EDU
Tue Dec 12 13:35:11 PST 2006


Brendan Eich wrote:
> On Dec 12, 2006, at 11:24 AM, Stepan Koltsov wrote:
>> 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";
>> }
> 
> This is a different kind of quoting than what " or """ means in JS or 
> Python.  It seems to me to warrant a different syntax, if it's worth 
> doing at all.  The counterargument besides "don't diverge from Python" 
> is: "just don't indent or add extra newlines you don't want in the 
> literal."

A further note on this: what you suggest here is the "post-processing" behavior of docstrings in Python.  From <http://docs.python.org/tut/node6.html#SECTION006760000000000000000>, "The Python parser does not strip indentation from multi-line string literals in Python, so tools that process documentation have to strip indentation if desired."  To an extent I agree that it would be convenient if leading whitespace were stripped from such string literals during actual program execution (and not just by docs post-processors), but I suspect you weren't aware (as I wasn't before looking this up!) that this step was a post-processing step, and that the actual string retained its indentation.

Jeff

-- 
Rediscover the Web!
http://snurl.com/get_firefox

Reclaim Your Inbox!
http://snurl.com/get_thunderbird



More information about the Es4-discuss mailing list