`ref T` should be a type!!

Walter Bright newshound2 at digitalmars.com
Mon Apr 1 10:37:00 UTC 2019


On 3/31/2019 6:30 PM, Manu wrote:
>> 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.

Um, have you looked at the special, kludgey rules for refs that permeate the C++ 
spec? Just about every rule for types has a special case for refs. For example, 
C++ does type inference in various contexts. Sometimes the ref is inferred, 
sometimes it is skipped. Can you describe when it is inferred and when it isn't, 
and why?


> 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++?

Yes. Keep in mind that I implemented ref in C++, every last gory detail. I've 
earned my opinion of it.



More information about the Digitalmars-d mailing list