Alternate declaration syntax

Koroskin Denis 2korden at gmail.com
Sat Apr 12 05:18:16 PDT 2008


Talking about multiple return values, I'd like to see the following syntax:

// both types are 'int's (just for simplicity)
[int, int] someFunction()
{
     return [1, 2];
}

instead of, for example,

Tuple!(int,int) somFunction()
{
     return Tuple!(int,int) {1, 2};
}

In fact, Tuple!(int,int) isn't that different from int[2].
They share 'length' property, and I like result[0] more than result._0,
'cause it's simpler, more intuitive and behaves just like built-in type:

auto result = someFunction();

auto len = result.length; // compile-time evalualable
auto r0 = result[0];      // types can be easily deduced
auto r1 = result[1];
auto r2 = result[2];      // fails to compile, out of bounds.

Whaddya think? :)



More information about the Digitalmars-d mailing list