Dynamic alter-ego of D.

Piotr Szturmaj bncrbme at jadamspam.pl
Tue Oct 25 03:31:13 PDT 2011


Gor Gyolchanyan 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.

If Algebraic/Variant could be recognized by the language it would give 
some interesting possibilities, like Variant array literals:

auto array = [10, 2.0, "abc"];

types it as Algebraic!(int, double, string)[];

auto AA = [ "a" : 10, "b" : 2.0, 3 : "abc" ];

types it as Algebraic!(int, double, string)[Algebraic!(string, int)];

for example, that may be used to express JSON structures with literals only:

int x, y;

auto json = [
     "x" : x,
     "y" : y,
     "colors" : [
         [
             r : 255,
             g : 0,
             b : 0
         ],
         [
             r : 0,
             g : 0,
             b : 255
         ]
     ]
]


More information about the Digitalmars-d mailing list