www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Idea for ported java static this?

reply "Frank Benoit (keinfarbton)" <benoit tionex.removethispart.de> writes:
I am porting Java code with a converter. Java is different from D in
many things. One of the problems is the static initialization of classes.

If i would add a "static this()" to every ported class, i would end up
in terrible 'cyclic dep' trouble.

So I decided to add a "public static static_this()" method to each
class, and generate a single file, that contains all calls to these
methods. I can edit the sequence. So it works, no problem so far.

Problem with this solution is, that this means, that all existing
classes are pulled in and the application size will grow.

How can i make sure, all static_this from linked in modules are called,
without having all modules forces to link in? Something like a weak
link-in ref :)

Any ideas?
Feb 15 2007
parent reply Walter Bright <newshound digitalmars.com> writes:
Frank Benoit (keinfarbton) wrote:
 How can i make sure, all static_this from linked in modules are called,
 without having all modules forces to link in? Something like a weak
 link-in ref :)
There's no way to do it now. But this should be possible with future runtime reflection stuff.
Feb 15 2007
parent "Frank Benoit (keinfarbton)" <benoit tionex.removethispart.de> writes:
 There's no way to do it now. But this should be possible with future
 runtime reflection stuff.
Ok, good to know.
Feb 15 2007