Auto return type inference issue?
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 22 01:23:27 PDT 2014
Matthew Dudley:
> Also, as an aside, why can't tuples be indexed dynamically?
> Most of my problems with this have been because you apparently
> can't.
Think about how D tuples are implemented, they are essentially
structs. Every tuple element can have a different type and to be
represented in memory with a different number of bytes. D is
statically typed so when you read an element of a tuple, you need
to know at compile-time the type (and size) of what you are
reading. To have tuples indexable at run-time their items need to
be all of the same type (so they are essentially arrays), or they
need to be some kind of variants (but later you need to manage
their type more manually).
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list