Lists And Missing Commas
Richard Damon
Richard at Damon-Family.org
Tue Dec 24 11:14:25 EST 2019
On 12/24/19 10:45 AM, Tim Daneliuk wrote:
> On 12/24/19 6:37 AM, Stefan Ram wrote:
>> And you all are aware that this kind of string concatenation
>> happens in C and C++, too, aren't you?
>>
>> main.c
>>
>> #include <stdio.h>
>> int main( void ){ puts( "a" "b" ); }
>>
>> transcript
>>
>> ab
> Noting that it has been a long time since I looked at the C specification ...
>
> Is the above an artifact of how puts() is implemented or is it innate in the language spec?
The automatic concatenation of adjacent strings is an innate part of the
C language spec.
One important reason this was included in the C language was so that
some of the predefined macros with a string value (like the compilation
time __TIME__) could be built into a string constant.
A second is that C had no equivalent to """ as a multi-line string
constant, and using line continuation was problematical on some systems
using fixed length lines, so allowing a constant to be built on multiple
lines was useful.
--
Richard Damon
More information about the Python-list
mailing list