indexing tuples using strings

Bill Baxter wbaxter at
Mon Dec 1 13:45:56 PST 2008

On Tue, Dec 2, 2008 at 6:40 AM, Jarrett Billingsley
<jarrett.billingsley at> wrote:
> On Mon, Dec 1, 2008 at 4:19 PM, llee <larry at> wrote:
>> Is is possible to index the elements within a tuple using strings?
>> Something similar to the way that associative arrays allow elements to be indexed using strings.
> No, because that makes no sense.
> What does tuple["string"] mean, anyway?

Tuples have an annoying "auto-flattening" behavior which means that
it's difficult to create very advanced data structures out of them.
But you can create a flat tuple a-list with entries like   "fred",
int, "barney", double, "wilma", ireal
Then you can write some template functions that will scan through the
list for a particular string and return the following type if there's
a match.  You will need to use lots of recursive template-fu.


More information about the Digitalmars-d mailing list