From: Giovanni P. Deretta (lordshoo_at_[hidden])
Date: 2005-04-26 17:22:05
Larry Evans wrote:
> But isn't an enumerator in some enumeration the equivalent of
> an "element tag"?
> The enumerator can also be thought of as a name.
> Which can be done with enumerators also.
and also yes.
> But again, I don't see why adding a tag is any better than using an
> enumerator. The only difference between an array (all elements of
> the same type) and a tuple, is that the type of the value as well
> as the value depends on the index. And if the types are indexed
> by the same enumeration, then you've solve the problem. In addition,
> a similar scheme can be used for variants (or disjoint sum). See
As your code demonstrates, enumerators can be used without duplicating
information, but an enum and map enum->type is required for each tuple.
This is verbose and should be wrapped in a macro. Then again, I don't
like macros a lot :)
In the end, getting 'by type' has the same expressive power of using
enumerators, i simply think that it would have a better syntax and it
would work out of the box with all tuples without the need of a map.
>> BTW, tuples containing many objects of the same type are better seen
>> as containers, thus the indexed get is fine.
> Agreed, but the indexed get works just as well when the argument is
> an enumerator instead of a literal unsigned, and when it's an
> enumerator, the meaning is clearer:
> is obviously not as clear as:
Well, i actually believe the first to be clearer. It is a matter of
-- Giovanni P. Deretta
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk