Move Constructor Syntax
Mike Shah
mshah.475 at gmail.com
Sun Oct 6 12:49:31 UTC 2024
On Sunday, 6 October 2024 at 05:40:40 UTC, Walter Bright wrote:
> On 10/5/2024 9:14 PM, H. S. Teoh wrote:
>> What about .opMove?
>
> I was thinking of using that for the move version of opAssign.
Perhaps opAssignMove? Slightly less ambiguous and consistent in
syntax for move assignment operator.
I agree a unique constructor is the way to go for grepping code.
My vote is option 1 or 3, with some thought process below.
'=this(S)' probably the cleanest, but might confuse beginners
with opEquals, opAssign, or capture syntax in C++. I imagine
easiest to implement/maintain in compiler though. Still looks
pretty good overall and we're use to the ~ mark on front of
destructors.
'this(=S)' Wonder if this opens doors for other symbols to appear
in parameters and have meaning? Are there other features we
foresee where we'd want to have symbol prefixes? Probably best to
avoid, as this would look better with @move, but that opens more
paths toward attribute soup imo.
'->this(S)' conveys what is going on(which I like -- I switched
the direction of the arrows). Easily searchable, and C and C++
programmers are used to typing it (but with a different but
otherwise clear meaning). Looks a tiny bit ugly though in the
code.
With any if these strategies, it seems we will then have a __move
or move type function otherwise ala std::move as I understand.
That seems consistent to me overall (at least for the C++ side of
my brain as I understand move semantics)
More information about the Digitalmars-d
mailing list