.
Any ideas how to implement variable length arrays under -betterC?
variable-length arrays (i.e. slices) are valid in betterC. What isn't
allowed is *GC-allocating* them and *appending* to them in betterC.
```d
int[] arr; // fine
// arr ~= 5; // nope, uses GC
arr = (cast(int *)m
On Tuesday, 18 April 2023 at 06:20:43 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 18/04/2023 1:33 PM, Salih Dincer wrote:
I understand from the thread this: D gives us -betterC but
nothing from the Phobos. So he says, see what you have, do
what the hell you want!
Am I wrong about this?
On 18/04/2023 1:33 PM, Salih Dincer wrote:
I understand from the thread this: D gives us -betterC but nothing from
the Phobos. So he says, see what you have, do what the hell you want!
Am I wrong about this?
Nope.
-betterC means you have no runtime or standard library support.
You are very
On Monday, 17 April 2023 at 19:12:20 UTC, user456 wrote:
... but you'll have to implement
- ctors
- concat assign
- slice assign
- copy construction
- value type elem alignment
- default elem construction
- default elem destruction
- etc.
to make that usable in on trivial cases.
I understand
allowed under -betterC.
[...]
Any ideas how to implement variable length arrays under
-betterC?
You need a struct with operator overloads and libc realloc(),
(very) basically
```d
struct Array(T)
{
private:
struct Payload
{
T* ptr;
size_t length;
}
Payload p
C:\D\dmd2\windows\bin\..\..\src\phobos\std\container\array.d(639):
instantiated from here: `RangeT!(immutable(Array!int))`
Array_ex_01v00.d(5):instantiated from here: `Array!int`
```
Any ideas how to implement variable length arrays under -betterC?