On Fri, Jul 10, 2009 at 09:13:39AM +0100, Robert Jones wrote:
So have I entirely missed the point of tuples?
The point is that tuple is the same type as any other tuple.
With ad-hoc structures,
struct A {int x, y; };
struct B {int x, y; };
the two are completely different types, so you can't write f.ex., a=b, whereas
you could do that with tuples. So tuples help to minimize the number of ad-hoc
structures in your program, and enable you to write code that is more generic..
[i.e., you can pass tuple from one subsystem of your program to
another with no problems, whereas it'd be more harder to pass A from subsys1
to subsys2 expecting B. you *could* implement implicit conversion operators
from A to B and vice-versa, but that sounds like calling for trouble..]
+ they predefine a number of useful operations for you, such as lexicographic
comparison, I/O operators, etc. With fusion maps, you get to use names,
instead of indexes. (fusion maps, in effect, replace a.x syntax with
at_key<x>(a) syntax.. somewhat more verbose, with the net win of the extra
functionality..)