digitalmars.D.learn - Tuple slicing fails
- Erik Baklund (28/28) May 14 2007 Hi,
- Bill Baxter (4/37) May 14 2007 I think your DMD is too old. Works fine here with v1.014. There were a...
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
May 14 2007
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
May 14 2007








Bill Baxter <dnewsgroup billbaxter.com>