--- Comment #7 from 2012-10-10 10:09:19 PDT ---
(In reply to comment #6)
> (In reply to comment #5)
> > OK, I think this can be implemented as a library trait.
> > 
> > Anyone want to send a pull request that adds it to std.traits?
> I can do it.
> I'll use the list here:
> Re-opening.

I wrote the code, the documentation, and the unit tests. The thing though is
that I don't really care for this enhancement, and don't feel like pushing for
it. I'm dumping my work here. May someone who cares for this (bearophile?) take
over it.

If $(D s) is a D reserved keyword, returns true.
bool isReservedWord(in string s)
    //Obtained from lexer.c, and sorted
    string[] reservedWords =
"__FILE__", "__LINE__", "__argTypes", "__gshared", "__overloadset",
"__parameters", "__thread", "__traits", "__vector", "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", "immutable", "import", "in",
"inout", "int", "interface", "invariant", "ireal", "is", "lazy", "long",
"macro", "mixin", "module", "new", "nothrow", "null", "out", "override",
"package", "pragma", "private", "protected", "public", "pure", "real",
"ref", "return", "scope", "shared", "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",

    auto found = reservedWords.assumeSorted().equalRange(s);
    return !found.empty;

void main()
    //obtained from lexer.c, not sorted
    string[] words =
"this", "super", "assert", "null", "true", "false", "cast", "new",
"delete", "throw", "module", "pragma", "typeof", "typeid", "template",
"void", "byte", "ubyte", "short", "ushort", "int", "uint", "long",
"ulong", "cent", "ucent", "float", "double", "real", "bool", "char",
"wchar", "dchar", "ifloat", "idouble", "ireal", "cfloat", "cdouble",
"creal", "delegate", "function", "is", "if", "else", "while", "for",
"do", "switch", "case", "default", "break", "continue", "synchronized",
"return", "goto", "try", "catch", "finally", "with", "asm", "foreach",
"foreach_reverse", "scope", "struct", "class", "interface", "union",
"enum", "import", "mixin", "static", "final", "const", "typedef",
"alias", "override", "abstract", "volatile", "debug", "deprecated",
"in", "out", "inout", "lazy", "auto", "align", "extern", "private",
"package", "protected", "public", "export", "body", "invariant",
"unittest", "version", "__argTypes", "__parameters", "ref", "macro",
"pure", "nothrow", "__thread", "__gshared", "__traits", "__vector",
"__overloadset", "__FILE__", "__LINE__", "shared", "immutable"
    foreach(ss; words)
    static assert(isReservedWord("this"));
    static assert(!isReservedWord("bar"));

So yeah, not assigned to me anymore :(

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to