[Python-ideas] Implicit string literal concatenation considered harmful?

Christian Tismer tismer at stackless.com
Wed May 15 14:18:35 CEST 2013


On 12.05.13 01:55, Greg Ewing wrote:
> Ian Cordasco wrote:
>> On Sat, May 11, 2013 at 2:52 PM, Mark Janssen 
>> <dreamingforward at gmail.com> wrote:
>
>>> It partitions the conceptual space.  "+" is a mathematical operator,
>>> but strings are not numbers.
>>
>> But + is already a supported operation on strings
>
> I still think about these two kinds of concatenation in
> different ways, though. When I use implicit concatenation,
> I don't think in terms of taking two strings and joining
> them together. I'm just writing a single string literal
> that happens to span two source lines.
>
> I believe that distinguishing them visually helps
> readability. Using + for both makes things look more
> complicated than they really are.
>

Thinking more about this, yes I see that "+" is really different
for various reasons, when you just want to write a long string.
"+" involves precedence rules, which is actually too much.

Writing continuation lines with '\' is much less convenient,
because you cannot insert comments.

What I still don't like is the pure absence of anything that makes
the concatenation more visible.
So I'm searching for different ways to denote concatenating of
subsequent strings.
Or to put it the other way round:
We also can see it as ways to denote the _interruption_ of a string.

Thinking out loud...
A string is built, then we break its construction into pieces that
are glued together by the parser.
Hmm, this sounds again more like triple-quoted strings.
Still searching...

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Software Consulting          :     Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121     :    *Starship* http://starship.python.net/
14482 Potsdam                :     PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776  fax +49 (30) 700143-0023
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
       whom do you want to sponsor today?   http://www.stackless.com/



More information about the Python-ideas mailing list