[Issue 24510] New: Perfect forwarding and explicit move should be compiler intrinsic and have operators
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 16 16:14:08 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24510
Issue ID: 24510
Summary: Perfect forwarding and explicit move should be
compiler intrinsic and have operators
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: qs.il.paperinik at gmail.com
Perfect forwarding parameters of parameters and explicit move requires
importing modules (that I have to look up every time and make no sense
naming-wise) and is quite unpleasant to look at in code. Last but not least,
the current implemenation of explicit move is ctfe-hostile, which makes no
sense as the compiler actually can move objects at ctfe. Both operations don’t
deserve that; they’re safe and useful.
My suggestion would be to make move (and forward, which boils down to either a
no-op or an explicit move) a compiler intrinsic. For both of them, there should
be unary operators: I suggest `>>` for forward and `<<` for move.
```d
f(move(x));
// becomes
f(<<x);
f(forward!xs);
// becomes
f(>>xs);
// xs can be a pack!
```
They’re both unary prefix operators with the same precedence as the other unary
prefix operators.
Rationale for the operator symbols:
They look very much alike, but that’s happenstance. `>>` looks like the the
"fast forward" icon. `<<` looks like an arrow pointing away from the object and
indicates: "Whatever is in here goes out of it."
--
More information about the Digitalmars-d-bugs
mailing list