Yet another MRV proposal!

Leandro Lucarella llucax at gmail.com
Mon Apr 14 12:36:32 PDT 2008


downs, el 14 de abril a las 11:23 me escribiste:
> Let's give this another try.
> The following proposal has the advantage that it's funded mostly on existing syntax.
> 
> An anonymous struct, in the position where you'd normally expect a function/method return type, is usable as the return type instead.
> 
> Example:
> 
> struct { int a; float b; } test() { return(1, 2f); }
> 
> writefln(test().a, test().b);

I think what you really want here is to return a tuple. I think adding
tuples to the language/library would be much more elegant. For example:

(int, float) test() { return (1, 2f); }

writefln(test()[0], test()[1]);

(I know the syntax it's no good, I wanted just to expose the concept).

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Vaporeso, al verse enfundado por la depresión, decide dar fin a su vida
tomando Chinato Garda mezclado con kerosene al 50%. Ante el duro trance
pierde la movilidad en sus miembros derechos: inferior y superior. En
ese momento es considerado como el hombre líder del movimiento de
izquierda de Occidente.



More information about the Digitalmars-d mailing list