Copy Constructor DIP

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jul 14 00:57:14 UTC 2018


On 7/13/18 5:49 PM, rikki cattermole wrote:
> On 14/07/2018 9:28 AM, Manu wrote:
>> I've already contributed other points to this DIP in the way you 
>> describe.
>> This one however is very strange, and I'm surprised you can find the
>> hand-wavy introduction of a new attribute without any sense of where
>> it's going to be okay. Or maybe, I'm surprised I'm the only one that
>> finds problem with that.
> 
> You are very much not alone.
> 
> I didn't articulate it very clearly, but I am super not happy with such 
> a new attribute.

It's a very simple process - @implicit is not invented as much as a given.

We need to distinguish a constructor from other constructors.

The constructor supports attributes.

Attributes are a mechanism for distinguishing declarations from other 
declarations.

Ergo, an attribute is the mechanism of choice.

Done deal.

=====

If we don't like the use of an attribute, it means we somehow failed in 
defining attributes in the first place. (I don't think we did; 
attributes as defined in D are brilliant and currently underused.) It's 
poor language design to define a mechanism for doing a category of Xs 
and then explicitly avoiding it exactly when the opportunity of doing X 
arises.

 From that vantage point, the choice of an attribute to identify 
implicit copy construction is unassailably obvious, and elucubrated 
syntax inventions such as "@this", "this(ref this x)" are chucklesomely 
profligate and ridiculously baroque.


Andrei


More information about the Digitalmars-d mailing list