Should out/ref parameters require the caller to specify out/ref like in C#?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon May 29 01:41:05 PDT 2017


On Monday, May 29, 2017 08:22:23 Ola Fosheim Grøstad via Digitalmars-d 
wrote:
> On Monday, 29 May 2017 at 07:51:13 UTC, Jonathan M Davis wrote:
> > I expect that we're going to see a DIP related to rvalue
> > references at some point here, because some of the folks
> > (particularly the game folks) think that it's critical to be
> > able to have a function that doesn't care whether it's taking a
> > value by value or by ref - just that it takes it efficiently,
> > and they don't want to be forced to use auto ref to do it
> > (since that requires templates).
>
> So it would use ref or value depending on the target platform? I
> guess that could make sense since some platforms allow vector
> registers as parameters, but it sounds more like an
> implementation detail?
>
> Or did you mean something else?

I probably didn't say it very well.

With C++, if you have const T&, it will accept both lvalues and rvalues. A
number of folks (particularly those writing games) want an equivalent to
that in D where they can then pass both lvalues and rvalues without
incurring a copy. Historically, Andrei has been against it because of issues
with rvalue references, but based on some of the more recent discussions, it
sounds like it _might_ be possible to come up with a solution that he'd be
okay with (particularly with some of the improvements that come with DIPs 25
and 1000). Ethan Watson has expressed interest in writing a DIP on the
matter, so I expect that we'll see one at some point here.

- Jonathan M Davis




More information about the Digitalmars-d mailing list