[Tutor] why inline-only string literals?

Alan Gauld alan.gauld at btinternet.com
Mon Feb 8 00:52:44 CET 2010

"Steve Willoughby" <steve at alchemy.com> wrote 

>> So, I wonder why most languages do not allow that from scratch;
>> and some, like python, need a special syntax for multi-line strings.
> to handle the case.  What happens too often, though, is that people
> forget a quote somewhere, so the compiler interprets that, plus a
> lot of lines of code following it, as a valid multi-line string,
> leading to confusion and possibly misleading error messages.  

Thats a good reason and I hadn't thought of it. 

My initial thought was that it was just historical since most 
early interpreters/compilers processed programs line by line.
Recall the dreaded line numbers of BASIC? So it made 
sense for strings (and comments) to be limited to a single line.
But modern languages are much more fluid (and Lisp was 
always so) and multi line comments and strings are more 
common. (As Python proves with its triple quote syntax)

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list