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. 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".

+1000, I really love this proposal; I *hate* that this point is still missing in D in 2017. It shouldn't even break existing code using `in` (but obviously the ABI) just because now a pointer to a const instance is passed instead of making a const copy.

Generic stuff: void foo(in T arg) // const scope ref => safe `const T&`
By-value optimizations: void foo(const T arg)

I love it.

Reply via email to