`ref T` should be a type!!

Manu turkeyman at gmail.com
Mon Apr 1 01:30:45 UTC 2019


On Sun, Mar 31, 2019 at 6:20 PM Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 3/31/2019 5:35 PM, Rubn wrote:
> > you can literally use it everywhere else you can use a type.
>
> No, you can't. An array of refs won't compile, either.
>
>    void test(int& a[]); // error

It could though with some innovative design, and that would be *awesome*.

> A C++ ref can only appear at the top of a type AST, which is unlike any other
> type. Which exactly matches the only place a storage class can be!

So, what you're saying is, C++ was able to implement storage class
semantics, but without distinguishing storage class from the type,
thereby making it accessible to any type construction or introspection
machinery that the language has available?

Apparently C++ was genius in this way; why would you invent storage
class specifically to exclude ref from the ability to interact with
type construction and introspection machinery? ref sucks because it
can't interact with type construction or introspection. Every
meta-interaction with ref is via kludgey hacks.

You mention the complexity of ref in C++, but that needs to be
balanced against the entire concept of 'storage class' in D, and
literally every single rule relating to it, since that's the
counter-weight. If you take the aggregate of all rules and semantics
related to 'storage class' in D, especially when including
consideration that we have lost the ability to do type construction or
introspection in storage classes, is that REALLY simpler than C++?


More information about the Digitalmars-d mailing list