Should 'in' Imply 'ref' as Well for Value Types?
kinke
noone at nowhere.com
Sat May 5 16:19:28 UTC 2018
On Saturday, 5 May 2018 at 15:22:04 UTC, Bolpat wrote:
> I once proposed that `in` can mean `const scope ref` that also
> binds rvalues.
> https://github.com/dlang/DIPs/pull/111#issuecomment-381911140
> We could make `in` be something similar to `inline`. The
> compiler can implement it as stated above (assign the
> expression to temporary, reference it), or use copy if copy is
> cheaper than referencing.
I remember, and I still like that proposal a lot, as it'd allow
the compiler to tune generic code to the targeted platform and
its ABI and free the dev from having to worry about how to pass a
read-only input argument in the most efficient way. So if `in`
semantics are ever to be redefined, `const [scope ref]`
(depending on type and target ABI) are the only ones I'd happily
agree with. [And I'd be extremely happy if rvalues could finally
bind to ref params, not just as prerequisite for this.]
More information about the Digitalmars-d
mailing list