Meta information parser

Sjoerd van Leent svanleent at gmail.com
Fri Jun 2 12:54:28 PDT 2006


I would be in agreement with all this. Yet I also consider that we 
shouldn't make code bloat when it isn't asked for. For an example, a 
device driver developer might not want to have access to runtime 
information and code emission, only perhaps for a small part of the 
software. The same goes for the GC. However, a business application 
developer does want to have such features.

The suggestion of using the pragma statement seems good enough. You 
could just write:

class Foo {
     void bar() {
     }
}
pragma(EnableReflection, Foo);


Which could then be used to enable reflection on the class Foo, 
generating another info part, within the global application scope. Same 
goes for making SOAP/CORBA or whatever kind of interop object. Just do:

class Foo {
     void bar() {
     }
}
pragma(EnableReflection, Foo);

Then do somewhere in a main routine or some general subroutine:

.
.
SoapRegister soap = new SoapRegister(80);
soap.add(Foo.reflectinfo);
soap.listen();
.
.

Same goes for CORBA, though be it a bit more complex. One could even 
emulate Java RMI, or eventually make a D Interface Registry, perhaps 
looking like a combination of COM, RMI and .NET GAC.

Besides the pragma statement, it might also be useful with some things 
to use the extern keyword:

extern (Reflective) class Foo {
     void bar();
}

Regards,
Sjoerd



More information about the Digitalmars-d mailing list