[Issue 2628] obj[n] not allowed for user-defined tuples

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 28 06:35:50 PST 2009


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





------- Comment #3 from andrei at metalanguage.com  2009-01-28 08:35 -------
(In reply to comment #1)
> > struct Tuple(T...)
> > {
> >    private T field;
> >    ref T[i] opIndex(size_t i) { return field[i]; }
> > }
> 
> That won't work as the return type of the function would depend on the function
> argument. At least until the requirement for CTFE functions to be evaluatable
> both at compile time and at run time is abolished.

Indeed. I also discussed that with Walter last night and allowing it is
possible but would have ripples through the rest of the compiler.

The feature can be allowed; the problem is that there's no obvious way to allow
it without making it a hack that people will need to learn.


-- 



More information about the Digitalmars-d-bugs mailing list