`in` no longer same as `const ref`
Q. Schroll via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jan 30 11:05:33 PST 2017
On Monday, 30 January 2017 at 12:08:06 UTC, Olivier FAURE wrote:
> On Monday, 30 January 2017 at 06:38:11 UTC, Jonathan M Davis
> wrote:
>> Personally, I think that effectively having an alias for two
>> attributes in a single attribute is a confusing design
>> decision anyway and think that it was a mistake, but we've had
>> folks slapping in on stuff for years with no enforcement, and
>> flipping the switch on that would likely not be pretty.
>>
>> - Jonathan M Davis
>
> I've always thought of 'in' as a visual shorthand for "this
> parameter doesn't care whether you give it a deep copy or a
> shallow reference", personally.
Would have been a far better definition. Why does anyone really
need a shorthand attribute for two attributes that could be
easily spelled out? You can type anything for "const scope"
while programming and then do search-and-replace. That's even
trivial.
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".
More information about the Digitalmars-d
mailing list