On Wed, Sep 10, 2025 at 05:15:16PM +0000, monkyyy via Digitalmars-d-learn wrote:
[...]
> I just do always enum; going all in on compile time abstractions

Be careful, this may not always be what you want. For example:

```d
enum data = [ 1, 2, 3 ];

void main() {
        auto buffer = data;     // GC allocation
        ...
        auto tmpBuf = data;     // another GC allocation
        ...
        assert(buffer is tmpBuf); // fails
}
```

Whereas:

```d
static immutable data = [ 1, 2, 3 ];

void main() {
        auto buffer = data;     // no GC allocation
        ...
        auto tmpBuf = data;     // no GC allocation
        ...
        assert(buffer is tmpBuf); // true
}
```


T

-- 
Never wrestle a pig. You both get covered in mud, and the pig likes it.

Reply via email to