What is the stance on partial initializers when declaring

bearophile bearophileHUGS at lycos.com
Thu Jul 21 17:50:52 PDT 2011


Simen Kjaeraas:

>      int n;
>      string s;
> 
>      unpack!(n,s) = tuple(4, "O HAI");

See my other answer. Beside being long and ugly, it doesn't define the types too. And you can't use it in foreach.

In my opinion a tuple syntax is more important than having built-in associative arrays. This means I'd like to remove D built-in associative arrays and replace them with built-in tuples. Tuples are more commonly useful than associative arrays, and in D there are enough ways to design a good enough library-defined AA.

The only problem are AA literals, but a bit of sugar can solve this problem too. In Scala associative arrays look good enough and they are fully in the library. There is just a -> built-in syntax to define 2-tuples, used to create AA literals.

Bye,
bearophile


More information about the Digitalmars-d mailing list