www.digitalmars.com         C & C++   DMDScript  

D - Tuple

reply "DeadCow" <deadcow-remove-this free.fr> writes:
What about introduction of tuple in D version 2 ?

So function/method take a tuple as parameter and return a tuple.
keyword "void" no longer exists, replaced by "()", the empty tuple.

it will solve many common problems.

// iterate over associative array
foreach( ( char[] key ,char[] value ) ; array.pairs )
    printf("%.*s -> %.*s\n" , key, value );

// swap
(a,b) = (b,a);

// mutiple return value
(int x,int y) = getCoord();


-- Nicolas Repiquet
Sep 13 2003
parent "Matthew Wilson" <matthew stlsoft.org> writes:
We're certainly going to need some mechanism when freaching (a new term?)
associative containers.

"DeadCow" <deadcow-remove-this free.fr> wrote in message
news:bjvfca$1dkf$1 digitaldaemon.com...
 What about introduction of tuple in D version 2 ?

 So function/method take a tuple as parameter and return a tuple.
 keyword "void" no longer exists, replaced by "()", the empty tuple.

 it will solve many common problems.

 // iterate over associative array
 foreach( ( char[] key ,char[] value ) ; array.pairs )
     printf("%.*s -> %.*s\n" , key, value );

 // swap
 (a,b) = (b,a);

 // mutiple return value
 (int x,int y) = getCoord();


 -- Nicolas Repiquet
Sep 13 2003