On 2009-06-03 10:54:55 -0400, grauzone <n...@example.net> said:

3. When you want template mixins to contain a static this, your approach doesn't really work at all. The template mixin obviously can't generate a new module to move the static ctor there. As an example for real life usage, look at BCS's serialization code. (See his thread on d.D.announce, code link is on his blog post.) He uses a template mixin containing a static ctor, to make a class "known" to the serialization system. Using a template mixin with static ctor is a nice way to hide that mechanism from the user, but it disallows cyclic module dependencies. I claim that many users, who try to substitute the lacking RTTI with a custom mechanism, will hit the same problem.

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.

A nice way to improve this that wouldn't require static this at all would be to have better runtime reflection in D so I could iterate over all classes and registering those implementing the ObjcObject interface using some kind of mixin-generated static functions which can be discovered at runtime.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to