`in` no longer same as `const ref`

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 30 11:46:41 PST 2017


On Monday, 30 January 2017 at 19:05:33 UTC, Q. Schroll wrote:
> Can't we make "in" mean "const scope ref", that binds on 
> r-values, too? Effectively, that's (similar to) what "const T&" 
> in C++ means. It's a non-copying const view on the object.

'ref' being separate from 'in' allows you to use both:

foo(in ref T x);
foo(in T* x);

However, I agree that 'in' should be the opposite of 'out' (const 
scope ref). Making the 'in' and 'out' keywords semantically 
asymmetrical just to save a few key strokes is dumb.

> We have the longstanding problem, one must overload a function 
> to effectively bind both l- and r-values. That is what I'd 
> suppose to be the dual to "out".

+1 on allowing rvalue to bind to 'const scope ref'...or 'in' done 
right.



More information about the Digitalmars-d mailing list