[Tutor] why inline-only string literals?

Steve Willoughby steve at alchemy.com
Sun Feb 7 18:54:12 CET 2010


> So, I wonder why most languages do not allow that from scratch;
> and some, like python, need a special syntax for multi-line strings.
> This is no parsing issue: instead, the pattern is simpler for it
> does need to refuse newlines!

I believe it's a deliberate design decision, not lack of ability to
parse multi-line strings.  You're right, it's easy for the compiler
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.  

So by making you explicitly state when you wanted multi-line strings,
it makes it easier to spot this common mistake as well as making
your intent more clear when just looking at the code.
-- 
Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.


More information about the Tutor mailing list