DIP 1016--ref T accepts r-values--Community Review Round 1

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Jul 21 01:17:40 UTC 2018


On Friday, July 20, 2018 18:04:26 Manu via Digitalmars-d wrote:
> On Fri, 20 Jul 2018 at 18:02, Manu <turkeyman at gmail.com> wrote:
> > [...]
> >
> > I think you're describing now a bug where a function returns an
> > lvalue, but it was meant to return an rvalue.
>
> Sorry, wrong way around! I meant to say:
> I think you're describing now a bug where a function returns an
> rvalue, but it was meant to return an lvalue (ie, a ref).

The function returning an rvalue isn't necessarily a bug. It's the fact that
it was then used in conjunction with a function that accepts its argument by
ref in order to mutate it. If a function accepts its argument by ref in
order to mutate it, then it's a but for it to be given an rvalue regardless
of whether the rvalue comes from. It's just that some cases are more
obviously wrong than others (e.g. passing foo + bad might be obviously
wrong, whereas passing foo.bar may be wrong but look correct).

- Jonathan M Davis



More information about the Digitalmars-d mailing list