Suggestions to triple quoted strings proposal
brendan at mozilla.org
Wed Dec 13 13:15:36 PST 2006
On Dec 13, 2006, at 10:59 AM, Stepan Koltsov wrote:
> Brendan, or anybody else who wants multiline strings should to behave
> like in Python,
> Could you please write complex-enough example of code with TQS? In
> that example string constant should be declared inside method inside
> class. There is no good example at
> http://developer.mozilla.org/es4/proposals/triple_quotes.html .
You're right there's no good example, but the Python docs have
examples, and real code has even more compelling examples. Two
1. "Be like Python, reuse brainprint from JS hackers who know Python
and Python hackers learning JS". This is non-trivial. It's not just
"marketing". It makes the world better to avoid defining """
differently in ES4/JS2 from Python.
2. "Be like Python, stand on its shoulders and reuse the experience
that informed its design decisions and defaults". This is certainly
a gamble, since JS is not Python, and Python ain't perfect (JS is far
from perfect). But with some care (e.g., eliminating GeneratorExit
in the JS Pythonic generators available now in Firefox 2, and going
into ES4), it can pay off. There's probably value here, unless
Python has failed to heed negative feedback on non-stripping """.
3. Quote means verbatim contents modulo escapes and special case for
embedded newlines, i.e. literal. Trimming or stripping does not fit
under the notion of "literal". Bob and I have made this point, it's
about intuition more than optimizing for the common case.
> I used to write in Python, I hated its """ behaviour. I asked people
> who use Python, and they generally agreed with me.
Were they writing doc strings or data? We have http://
documentation, that is, Java doc-comments with simpler embedded
> I'm afraid, that if you keep TQS "simple", they won't be very usable:
> in 99% cases users will be forced to manually strip spaces and leading
> newline. In 1% cases string constant will be defined outside block, or
> amount of spaces will not matter.
> I have no other arguments :)
This is the crux of the matter. My counter-argument is number 2,
above. If your Python experience were more common, something would
have been done. But I could be wrong.
Can you say more about what these """ strings contained in Python
(doc vs. data, etc.). More context, real examples?
More information about the Es4-discuss