C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] The new new thing
From: Matt Hurd (matthurd_at_[hidden])
Date: 2020-02-21 07:18:50


>
> Matt, if this were to become a language thing, I don't see how the above
> could be done so easily. I also wonder how it would handle a function
> declaration that occurs /after/ the "using new" statement. If A and B are
> both using new X, and a function f(X, X) is declared after the definitions
> of A and B, is f(A, A) valid? f(A, B)?
>

Thank you for the feedback.

My simplistic view of "using A = new X" or "using new A = X" or
"using_otherwise_adorned A = X" is simply to be similar to "struct A {}"
where A is "clone" of X but not an alias in the type system. I imagine
extension methods to add methods would be useful in this picture but
somewhat orthogonal.

Perhaps to handle your example of preventing ops in an inappropriate
domain, such as the time add, = delete or extension removal would also make
sense. That is, using an extension method for adding the delta and an
extension deletion for removing the addition of time to time.

Such a slightly different way of looking at the type system may also make a
contribution to the ABI/performance debate.

I'm not sure if adding data to a clone would also make sense due to the
layout changes. I can see it being useful but *different* from both cloning
a type and inheritance as an alternative composition technique.

Kind regards,

--Matt.



STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups