Should out/ref parameters require the caller to specify out/ref like in C#?
Dukc via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 29 08:09:03 PDT 2017
On Monday, 29 May 2017 at 07:46:07 UTC, Stanislav Blinov wrote:
> On Monday, 29 May 2017 at 07:39:40 UTC, Dukc wrote:
>
>> [snip]
>
> Explicitly? It is:
>
> import std.stdio;
>
> struct S
> {
> int v;
> }
>
> void foo(ref S s)
> {
> writeln("took S by ref: ", s.v);
> }
>
> void foo(S s)
> {
> writeln("took rvalue S...");
> foo(s); // calls ref overload
> }
>
> void main()
> {
> S s;
> foo(s); // calls ref overload
> foo(S.init); // calls rvalue overload
> }
>
> And for templates we have auto ref.
Of course, I should have noticed one can already do it that way.
No need for change, then (imo).
More information about the Digitalmars-d
mailing list