Tuple slicing fails
Erik Baklund
ebaklund at hotmail.com
Tue May 15 15:25:40 PDT 2007
Bill Baxter Wrote:
> Erik Baklund wrote:
> > Hi,
> >
> > I am trying to understand tuples.
> > Does anybody know why line 11 below fail?
> > Is it conceptually wrong or is it a compiler glitch?
> >
> > Erik
> >
> > 1 import std.stdio;
> > 2
> > 3
> > 4 template Tuple1(E...)
> > 5 {
> > 6 alias E Tuple1; // Works
> > 7 }
> > 8
> > 9 template Tuple2(E...)
> > 10 {
> > 11 alias E[0..length] Tuple2; // Sematicly the same (?) but fails
> > 12 }
> > 13
> > 14 int main (char[][] args)
> > 15 {
> > 16 writefln(Tuple1!(3, 7L, 6.8));
> > 17 writefln(Tuple2!(3, 7L, 6.8));
> > 18
> > 19 return 0;
> > 20 }
> >
> >
> > a.d(11): tuple E is used as a type
> > a.d(11): Error: can only slice tuple types, not void
> > a.d(17): template instance a.Tuple2!(3,7L,6.8) error instantiating
>
> I think your DMD is too old. Works fine here with v1.014. There were a
> number of problems like that in older versions of dmd.
>
> --bb
Thank you Bill,
Good to know that I am on the right track with respect to tuples.
I was running of the posted stable version 1.010 at http://ftp.digitalmars.com/dmd.zip.
Based on your feedback, I will try the 1.014.
Kind regards,
Erik
More information about the Digitalmars-d-announce
mailing list