How is `auto` and not `alias` appropriate for alias sequences?
Shriramana Sharma via Digitalmars-d
digitalmars-d at puremagic.com
Fri Dec 11 22:15:10 PST 2015
Another twist to this is that the tuple created by .tupleof doesn't really
seem to be a new object of type Tuple!() but rather a "view" of sorts onto
the original object itself in the form of a tuple, else the example provided
at http://dlang.org/spec/class.html i.e.:
class Foo { int x; long y; }
void test(Foo foo)
{
foo.tupleof[0] = 1; // set foo.x to 1
foo.tupleof[1] = 2; // set foo.y to 2
foreach (x; foo.tupleof)
write(x); // prints 12
}
wouldn't be able to set values to the original class instance via whatever
.tupleof generates.
So the exact nature of the object produced by .tupleof is still a mystery to
me. Would be good if someone threw more light on it.
Also: what is the use of presenting the members of a struct/class as a
tuple? Is it iteration?
--
Shriramana Sharma, Penguin #395953
More information about the Digitalmars-d
mailing list