`in` parameters made useful
r.sagitario at gmx.de
Sat Aug 1 07:48:10 UTC 2020
I like most of your proposal, but
On 31/07/2020 23:49, Mathias LANG wrote:
> B) It makes `in` take the effect of `ref` when it makes sense. It always
> pass something by `ref` if the type has elaborate construction /
> destruction (postblit, copy constructor, destructors). If the type
> doesn't have any of those it is only passed by `ref` if it cannot be
> passed in register. Some types (dynamic arrays, probably AA in the
> future) are not affected to allow for covariance (more on that later).
> The heuristics there still need some small improvements, e.g. w.r.t.
> floating points (currently the heuristic is based on size, and not
> asking the backend) and small struct slicing, but that should not affect
Please note that many C/C++-ABIs already define similar rules for
passing function arguments by value (referencing a copy on the stack).
It might not be the best idea to stack two similar, but maybe slightly
conflicting rule sets.
Maybe we can leverage that and define that if the ABI uses a reference
for an `in`-value, the compiler may/must elide an extra copy. That
avoids having to define our own rule set.
More information about the Digitalmars-d