static this sucks, we should deprecate it

grauzone none at example.net
Wed Jun 3 16:17:39 PDT 2009


> I had the same problem when writing the D/Objective-C bridge. Basically, 
> if you ask the Objective-C runtime to instanciate a class not previously 
> registered, it won't find it. My choice was to require manual 
> pre-registrations of the classes you want to use, and register 
> everything that is possible lazily as soon as you use a bridged class.

Yes, and that "pre-registration" is only there to make the compiler 
generate the required compile-time reflection code (like with .tupleof 
or __traits). While compile-time reflection is probably really more 
flexible than runtime reflection, requiring this kind of "registration" 
remains a weakness of the compile-time approach.

Solutions would be to make reflection fully dynamic (as you said) and 
extend RTTI for that, or to provide better ways to inspect modules as a 
whole.

For the latter, maybe __traits should just be able to inspect all 
members of a module, and to follow imports. Or one could introduce some 
kind of "module preprocessor", which enables you to execute code for 
each module at compile time (transparent for the processed module).

Just by the way, annotations would also be nice. It's annoying to add 
additional information to members without them. This "additional 
information" can be stuff like default values, versioning of 
serializable members, behavior for missing values on deserialization, 
human readable help text if you want to use reflection to read/write 
user configuration files...



More information about the Digitalmars-d mailing list