Matching with std.concurrency receive

Adam Adam at anizi.com
Sat Dec 10 13:23:28 PST 2011


Hm.. so I tried another approach, which would be to send the type
name as a string, then use Object.factory to instantiate that (ugly,
but whatever). Had a few problems with that, then just reduced it to
a non-thread case:


import std.stdio;

immutable interface BasicType {
}

immutable class SubType : BasicType {
}

immutable class A(T : BasicType) {
}

void main() {
    immutable A!(SubType) instance = new immutable(A!(SubType))();
    writeln("Type name is " ~ instance.classinfo.name);
    Object object = Object.factory(instance.classinfo.name);
    if (object) {
        writeln("Created");
    } else {
        writeln("Failed");
    }
}

This returns "Failed." So, I thought I'd just provide Object.factory
"hello.A" (since hello is the module name and is what is printed
from the writeln). Still no good.

Any thoughts?


More information about the Digitalmars-d-learn mailing list