Is implicit string literal concatenation a good thing?
Brad Roberts
braddr at puremagic.com
Sun Feb 22 01:34:25 PST 2009
Frank Benoit wrote:
> Find the bug:
> static string[] KEYWORDS = [ "abstract", "alias", "align", "asm",
> "assert", "auto", "body", "bool", "break", "byte", "case",
> "cast", "catch", "cdouble", "cent", "cfloat", "char", "class",
> "const", "continue", "creal", "dchar", "debug", "default",
> "delegate", "delete", "deprecated", "do", "double", "else",
> "enum", "export", "extern", "false", "final", "finally",
> "float", "for", "foreach", "foreach_reverse", "function",
> "goto", "idouble", "if", "ifloat", "import", "in", "inout",
> "int", "interface", "invariant", "ireal", "is", "lazy", "long",
> "mixin", "module", "new", "null", "out", "override", "package",
> "pragma", "private", "private:", "protected", "protected:",
> "public", "public:", "real", "return", "scope", "short",
> "static", "struct", "super", "switch", "synchronized",
> "template", "this", "throw", "true", "try", "typedef", "typeid",
> "typeof", "ubyte", "ucent", "uint" "ulong", "union", "unittest",
> "ushort", "version", "void", "volatile", "wchar", "while",
> "with", "~this" ];
>
> There is a comma missing : "uint" "ulong"
I have a personal style rule that says: if a list like that (be it
function parameters, initializers, whatever) is more than one line, it's
one element per line. I hate having to visually parse things, or play
the re-wrap game as the lists change. I hadn't really thought about,
until now, the side benefit of making it easier to spot missing trailing
commas.
Back in c and c++, with it's pre-processor, merging adjacent string
literals is very handy. In D, it's only marginally so, but not
completely useless. It can still be used to break a really long string
literal into parts. There's other string boundary tokens in D which
might well provide viable alternatives.
Just my two cents,
Brad
More information about the Digitalmars-d
mailing list