array of elements of various sybtypes

Steven Schveighoffer schveiguy at yahoo.com
Wed Jan 26 18:59:50 PST 2011


On Wed, 26 Jan 2011 18:28:12 -0500, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:


> I believe that it's supposed to take the common type of t1 and t2 and  
> make the
> result an array of that type. So, assuming that the common type is T0,  
> then it
> should work. However, it's not currently implemented that way. You could  
> always
> create a bug report so that it doesn't get lost (assuming that no such  
> report
> already exists).
>

Object could also be the common type.  When there exists multiple  
possibilities, and none of the possibilities are types being passed to the  
array literal, I think it just gives up (D usually gives up in the face of  
ambiguity, instead of possibly making the wrong decision).

But the problem here appears that there is no way to *force* it to make  
the right decision.

I'd like to see cast(T0[])[...] work, I think that should solve the  
problem.

-Steve


More information about the Digitalmars-d-learn mailing list