Second Draft: Placement New Expression
Quirin Schroll
qs.il.paperinik at gmail.com
Thu Jan 16 03:17:24 UTC 2025
On Tuesday, 19 November 2024 at 03:47:09 UTC, Walter Bright wrote:
> https://github.com/WalterBright/documents/blob/37206e8aad453aa115329f4465fc5b83bca4ff66/placementnew.md
>
> as the first draft did not survive the implementation:
>
> https://github.com/dlang/dmd/pull/17057
I feel the need to point out that the proposed grammar puts
another spoke in my wheel for primary type syntax: What is `new (
… ) ( … )`?
Could be `new(buffer) (Type)` (with implicit `()` arguments).
Could be `new (Type)(CtorArg)`.
The issue is that the buffer is not distinguished. A simple
solution would be to delineate the buffer with `in`:
```d
struct S { float d; int i; char c; }
void[S.sizeof] buffer = void;
S* ptr = new in(buffer) S(1, 2, 3);
// or
S* ptr = new S(1,2,3) in buffer;
```
More information about the dip.development
mailing list