array of elements of various sybtypes

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Jan 27 09:49:33 PST 2011


On 1/27/11, spir <denis.spir at gmail.com> wrote:
> The latter fails because because you did an error. Indeed D cannot cast a
> /string/ of immutable chars to a char type.
>      writeln(typeid( [cast(immutable(dchar)[])"a", "b", "c"] ));
>      // immutable(dchar)[][]

My bad! :)

This is what I should have typed:
writeln(typeid( [cast(dstring)"a", "b", "c"] ));

>  By
> analogy, the only thing I can imagine is postfixing the (element type) to
> the
> literal:
>       auto ts = [t1, t2]T0;
> But it's not really beautiful ;-)
>

Well, I wasn't implying that we need a special postfix syntax for
custom types (honestly, at this stage any feature request gets shot
down and buried 6 feet under by the D town sheriff and his deputy).

Maybe all that needs changing is the compiler so it can at least try
to find a common type.


More information about the Digitalmars-d-learn mailing list