On Sunday, January 31, 2016 17:48:53 maik klein via Digitalmars-d-learn wrote: > On Sunday, 31 January 2016 at 17:42:19 UTC, anonymous wrote: > > On 31.01.2016 18:21, Matt Elkins wrote: > > I don't know if this works in all cases, but it passes that > > simple test: > > > > ---- > > @disable void foo(ref int x); > > void foo(int x) {} > > > > void main() > > { > > foo(5); /* works */ > > int y = 5; > > foo(y); /* error */ > > } > > ---- > > The problem is that x will be copied afaik which is not what you > want if you want to deal with ownership.
In D, if you pass an rvalue to a function or assign it to a variable, then it's going to be moved, not copied. So by making it illegal to pass an lvalue to a function, you guarantee that every argument it gets was moved and not copied. - Jonathan M Davis