DIP1000: Walter's proposal to resolve ambiguity of ref-return-scope parameters
Dennis
dkorpel at gmail.com
Fri Nov 26 10:02:17 UTC 2021
On Friday, 26 November 2021 at 09:19:45 UTC, Araq wrote:
> What is a "storage class"?
A property of a variable declaration that says something about
the memory it is stored in. In C, that could be e.g. `register`
or `volatile`. In D, that could be `__gshared`, which says a
global variable is stored in the data section instead of thread
local storage (default).
> And assuming this terms means anything, why would "ref" be one?
It's a property of a parameter (which is a variable declaration)
that says it's not stored in this function's frame, but somewhere
higher up.
> In what world is a hidden pointer a "storage class"?
You don't explicitly spell out the `this` parameter in member
functions, but `ref` is not 'hidden'.
You are right though that making `ref` a storage class is a
questionable decision, it adds a lot of complexity to the
compiler, which has tons of split code paths (a search for
`isref` gives me 229 hits). Same for `scope`, which is also
questionable as a storage class: it doesn't even say anything
about the variable itself, only about the variable that the
pointer points to.
More information about the Digitalmars-d
mailing list