Are Delimited strings and HereDoc strings just here to suck ?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 11 13:09:08 PDT 2014


On Mon, Aug 11, 2014 at 07:47:44PM +0000, Klaus via Digitalmars-d-learn wrote:
> I mean when writing a D lexer, you necessarly reach the moment when
> you think:
> 
> "Oh no! is this feature just here to suck ?"

I use heredocs every now and then when I need to embed long strings in
my program. It's one of the things I *like* about D, in fact. Nobody
wants to manually parenthesize every quoted line with '"...\n"' when the
program need to incorporate several pages of built-in help text, for
example.

Delimited strings are useful when writing code/text generators when you
need to be able to use ' and " as literal characters without crazy
leaning-toothpick syndrome \"x\"y\"z\"w\"'s sprinkled everywhere.

The crazy variety of ways to write string literals in D, OTOH, *is* a
bit over the top, as I found out myself when I also tried writing a D
lexer.  :-P


T

-- 
LINUX = Lousy Interface for Nefarious Unix Xenophobes.


More information about the Digitalmars-d-learn mailing list