Yet another MRV proposal!
Janice Caron
caron800 at googlemail.com
Tue Apr 15 00:05:33 PDT 2008
On 15/04/2008, Clay Smith <clayasaurus at gmail.com> wrote:
> If there is MRV I don't see why not take the python route and support
> tuples.
I agree. Particularly as we already have tuples (std.typecons.Tuple),
so really all that we need now is a little bit of syntactic sugar.
Something like:
BEFORE
import std.typecons
Tuple!(int,float) test()
{
return Tuple!(int,float)(1,2);
}
auto t = test();
int a = t._0;
float b = t._1;
AFTER:
{int,float} test()
{
return {1,2f};
}
{a,b} = test();
or similar. The implementation can still be in std.typecons, but the
compiler could save you a bit of typing.
Incidently, std.typecons.Tuple can already name the fields.
Tuple!(int,"a",float,"b"}
is basically the same thing as
struct anon { int a; float b; }
but most of the time, there's little need to name the fields, as _0,
_1 etc. suffice, and if we add some syntactic sugar, we won't even
need those.
More information about the Digitalmars-d
mailing list