Yet another MRV proposal!

Tower Ty tytower at hotmail.com
Mon Apr 14 14:36:45 PDT 2008


downs Wrote:

> 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);
> 
> The compiler would translate this into "current D" as follows:
> 
> struct _D_anonymous_struct_1 { int a; float b; }
> _D_anonymous_struct_1 test() { return _D_anonymous_struct_1(1, 2f); }
> 
> Because of the not-exactly-clear type name, it is necessary to store the returned value in an auto/const/static variable.
> 
> This looks like it could be ambiguous, but it really isn't - the two conditions required here - an unnamed struct in the position where a return type would be expected - are quite unambiguous :)
> 
> Whaddya think?
> 
>  --downs


Whaddya think?  -It wold be nice to be able to read it in plain english
"it's funded mostly on existing syntax" -funded means we are using money
"ot-exactly-clear "- err not really sure ?
"auto/const/static variable"- this must be a new type of multi-variable ?



More information about the Digitalmars-d mailing list