Yet another MRV proposal!
Georg Wrede
georg at nospam.org
Mon Apr 14 15:05:56 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.
An interesting idea.
> 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); }
One might use this especially with inner functions, where the entire
scope fits on screen.
But still, the concept of MRV is much larger, and to make decent use of
MRV, the language would have to have many other facilities, IMHO.
More information about the Digitalmars-d
mailing list