Copy Constructor DIP

Manu turkeyman at gmail.com
Sat Jul 14 01:17:19 UTC 2018


On Fri, 13 Jul 2018 at 18:00, Andrei Alexandrescu via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> 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.

But you surely recognise that D has a lot of intrinsic attributes
already, and that's a lot of mental (and visual) baggage to carry
around.
If we add a new intrinsic attribute, I would want to be sure it's
widely useful, because every D user will need to learn about and
understand it.
It's much easier to learn, and more useful knowledge to have, if it
has a broad meaning which solves a general class of problem, than just
a marker that you need to remember you have to type in one specific
niche location.


More information about the Digitalmars-d mailing list