crazy tuple ideas.

Russell Lewis webmaster at villagersonline.com
Mon Mar 5 11:22:56 PST 2007


Daniel Keep wrote:
> 
> +1 on nested tuples, although the symbols appearing unquoted is somewhat
> iffy.

I agree that nested tuples would be cool, though I'm not 100% sure what 
the syntax should be.  Perhaps the existing syntax (where tuples are 
unrolled by default) needs to be made more explicit.

However, you can already roll your own nested tuples, at least for some 
things.  You can take a type-tuple and create a struct:
   struct TupleBoxer {
     MyTuple elements;
   }
and although I haven't written one, yet, I bet that you could write a 
template which would do the same with expression-tuples.  Note that you 
can encapsulate an expression in a struct like this:
   struct ExpressionBoxer {
     static const uint foo = <myExpression>;
   }
and so you should be able to write a template which takes an 
expression-tuple and builds a struct like that for you.  Perhaps type 
deduction makes this really easy?

I'm not saying that any of this is as good as nested Tuples, but it's a 
start.



More information about the Digitalmars-d mailing list