Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
|
|
Subscribe / Log in / New account

Implicit string literal concatenation considered harmful?

From:  Guido van Rossum <guido-+ZN9ApsXKcEdnm+yROfE0A-AT-public.gmane.org>
To:  Python-Ideas <python-ideas-+ZN9ApsXKcEdnm+yROfE0A-AT-public.gmane.org>
Subject:  Implicit string literal concatenation considered harmful?
Date:  Fri, 10 May 2013 11:48:51 -0700
Message-ID:  <CAP7+vJLwOofbDp1X9Ys_aN-4MPaAdqo6J2v+iCrqS7pFtOdbRQ@mail.gmail.com>

I just spent a few minutes staring at a bug caused by a missing comma
-- I got a mysterious argument count error because instead of foo('a',
'b') I had written foo('a' 'b').

This is a fairly common mistake, and IIRC at Google we even had a lint
rule against this (there was also a Python dialect used for some
specific purpose where this was explicitly forbidden).

Now, with modern compiler technology, we can (and in fact do) evaluate
compile-time string literal concatenation with the '+' operator, so
there's really no reason to support 'a' 'b' any more. (The reason was
always rather flimsy; I copied it from C but the reason why it's
needed there doesn't really apply to Python, as it is mostly useful
inside macros.)

Would it be reasonable to start deprecating this and eventually remove
it from the language?

-- 
--Guido van Rossum (python.org/~guido)



to post comments


Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds