Just where has this language gone wrong?
Simen Kjaeraas
simen.kjaras at gmail.com
Tue Jul 24 07:59:25 PDT 2012
On Tue, 24 Jul 2012 16:42:19 +0200, Stuart <stugol at gmx.com> wrote:
> You mean it's already supported? Nice!
That's what I mean. :p
> Although, It'd still be awesome to be able to do things like:
>
> auto a,b = bar();
>
> auto c,_ = bar();
That would be nice, and has been on the table numerous times.
Nothing has yet been implemented, and I don't think even a
syntax has been decided upon, so we might never see that.
The closest thing we have is probably this:
int a = 1;
int b = 3;
TypeTuple!(a,b) = tuple(b,a); // Look ma, I'm swapping!
assert(a == 3);
assert(b == 1);
...which inspired me to write this implementation of fibonacci:
T fib(T = int)(int n, T a = 0, T b = 1) {
while ( n-- ) {
TypeTuple!(a,b) = tuple(b, a +b);
}
return a;
}
--
Simen
More information about the Digitalmars-d
mailing list