[Issue 7318] Cannot concatenate arrays of super- and subtype

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 20 07:50:08 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7318



--- Comment #7 from Steven Schveighoffer <schveiguy at yahoo.com> 2012-01-20 07:50:06 PST ---
(In reply to comment #6)
> > I could use a template to do the job:
> > 
> > ref A[] append(A,B)(ref A[] x, B[] y) if(is(B:A)) {
> >     foreach(e; y){
> >         x.length++;
> >         x[$-1] = e;
> >     }
> >     return x;
> > }
> > 
> > (it is more general than built-in append, but that could be fixed with a better
> > constraint)
> 
> This suggests that the compiler should simply translate e1 ~= e2 into
> .object.append(e1, e2) and let druntime take care of the rest. One up for
> moving decisions from the compiler to the runtime.

This would also solve the problem, but would possibly generate unnecessary
template bloat.  However, inlining should take care of that problem.

I'm all for the compiler translating things into expressions that can be hooked
instead of functions that can be hooked.  It makes things much more
upgradable/flexible.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list