Unexpected result with -betterC
Paul Backus
snarwin at gmail.com
Sun Nov 3 20:25:24 UTC 2024
On Sunday, 3 November 2024 at 19:00:33 UTC, DLearner wrote:
> However, the docs say dynamic arrays are not allowed with
> betterC, and 'string' implies a dynamic array.
> So I expected DMD to complain that my code was invalid.
>
> Any ideas?
The docs are wrong. Dynamic arrays themselves are allowed; you're
just not allowed to perform any *operations* on them that would
cause memory allocation.
This includes, for example,
- concatenating two dynamic arrays with the `~` operator.
- appending to a dynamic array with the `~=` operator.
- extending a dynamic array by assigning to its `.length`
property.
- copying a dynamic array using the built-in `.dup` method.
More information about the Digitalmars-d-learn
mailing list