I think, D is a typesafe language, therefore you can't use variables with no type declaration.

One thing you can search for, are templates but even there you have to define a type:

import std.stdio;

enum Category : string { first = "first"}

template Pair(T)
{
        T t;
        T cat;
}


void main()
{
        alias Pair!(string) a;
        a.cat = Category.first;
        a.t = "first";

        writeln(a.cat, " . ", a.t);
}

Ok. I know that D is typesafe language, but I'm not going to do some implicit type casts in there, because type of Category.first is Category itself but not string or something. In this example `a.cat = Category.first;` tries to make implicit cast (I don't remember is it allowed or not)

Reply via email to