Dynamic alter-ego of D.

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 26 07:09:43 PDT 2011


On Tue, 25 Oct 2011 06:00:28 -0400, Gor Gyolchanyan  
<gor.f.gyolchanyan at gmail.com> wrote:

> I think adding more dynamic typing to D would be a splendid idea to
> further widen the variety of solutions for different problems.
> Modular app development is a very good practice and modularity means
> dynamicity, which in turn means, that one needs to give up on lots of
> sweet stuff like templates, overloading and string mixins.
> Variant is the first step towards dynamic alter-ego of D, which is
> completely undeveloped currently.
> Although my benchmarks show, that variant is quite slow and I'd really
> like a version of variant, optimized for ultimate performance.
> Also, there are lots of stuff, that i really need at run-time, which i
> only have at compile-time:
> * Interfaces. dynamic interfaces are very important to highly modular
> applications, heavily based on plugins. By dynamic interfaces i mean
> the set of attributes and methods of an object, which is only known at
> run-time.
> * Overloading. A.K.A multimethods. required by dynamic interfaces.
> * Dynamic templates. In other words, value-based overloading (since
> type is yet another attribute of dynamically typed data).
>
> Dynamic interfaces are also different from static ones because the
> interface isn't _implemented_ by a type, it's _matched_ by a type,
> which means, that if a type fits into an interface at run-time, i can
> safely cast it to that interface type and work with it.
>
> Being able to obtain the dynamic version of a delegate would be great
> to pass around generic callbacks.

Have you looked into opDispatch?

I think with opDispatch and some Variant[string] member, you should be  
able to implement fully dynamic types.  I think even some have done this  
in the past (even if only for proof of concept).

-Steve


More information about the Digitalmars-d mailing list