www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Do we already have full compile time / runtime separation?

Content-Type: Text/Plain;
Content-Transfer-Encoding: quoted-printable

I've been trying to manage this on my own for like 2 days but still couldn'=
do that, and because my brain just suddenly turned-off, I would ask You for=
some guidance.

The thing is:
I'd like to make some kind of messaging in my application. So, there is=20
=2D interface Msg
=2D classes that are implementing it, i.e. MsgWindowClose
=2D interface Provider for message publishers, i.e. MsgProviderWindowClose
=2D interface Listener for message subscibers i.e. MsgListenerWindowClose
=2D interface Handler for message filters i.e. bool MsgHandlerWindowClose.l=
=2D interface Mediator for message passing between program classes, i.e.=20
MsgMediatorDMultiThreading() - which is using D messages btw.

Nothing related to D so far. Key thing is, that most of this Msg objects wi=
be really generic, so I'm building object generator, i.e=20
template MsgProviderGen(string MSG, Args...) {
	const char[] MsgProviderGen =3D "class MsgProvider"~MSG~" : MsgProvider {"
			~"override Msg"~MSG~" getMsg() {"
				~"return new Msg"~MSG~";"
Which will be bigger of course.

Then, for standard and generic messages i can easily define:
private import

class MsgWindowClose : Msg {

So far so good, but then if I'd like to add
<code>mixin("immutable uint id=3D"~static_id~";")</code>
for each *class* (not object) I got a=20

Each compile-time variable has to be const, right? So I can't increment my=
`static_id` each time I build a class (how many times template has generate=
provider/listener of this type). This wont let me statically check if each=
listener has its provider.

Surely it's not the only use of this feature, For loosen coupling, I'd wish=
add function that statically returns array of Msg defined in module. It isn=
an option without compile-time variables too.

Is it something about undefined module initialization?
Or maybe there is any way to overcome this problems, since I'm still new   =

Ps. How to make associative array of dynamic arrays?
<code>MsgHandler[hash_t][] _handlers =3D new MsgHandler[hash_t][];</code>
wont work.

Thanks for help,
Mariusz Gliwi=C5=84ski
Dec 23 2010