array of elements of various sybtypes

Jonathan M Davis jmdavisProg at gmx.com
Wed Jan 26 19:10:58 PST 2011


On Wednesday 26 January 2011 18:59:50 Steven Schveighoffer wrote:
> 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.

It probably doesn't for the exact same reason that the assignment didn't do it. 
The expression is evaluated and _then_ it's cast. So, if the expression isn't 
valid in and of itself, it fails.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list