Tuple literal syntax
Simen kjaeraas
simen.kjaras at gmail.com
Thu Oct 7 14:07:16 PDT 2010
Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> I do want to introduce syntax for expansion a la
>
> auto (a, b) = foo(42);
>
> because that's a common need that's not satisfiable via a library. But
> then I want to define the syntax in a general way so it works not only
> with tuples, but also with arrays and types that implement opIndex.
Philippe Sigaud's reftuple[1] from dranges does that first part:
int a, b;
_(a,b) = tuple(b,a); // swap
_(a,b) = tuple(b,a+b); // fibonacci
[1]:
http://svn.dsource.org/projects/dranges/trunk/dranges/docs/reftuple.html
--
Simen
More information about the Digitalmars-d
mailing list