On Wednesday, 8 October 2025 at 08:48:12 UTC, Kagamin wrote:
To be pedantic, strong purity requires immutable arguments, const are not enough:
```
void main()
{
        import std.stdio : writeln;

        int[] numbers = [5, 6, 7, 8, 9];
        writeln("numbers before: ", id(numbers));
        numbers[0]=1;
        writeln("numbers after : ", id(numbers));
}

const(int)[] id(const int[] p) pure
{
        return p;
}
```

Yes, thank you for the correction.

I got this confused with pure factory functions, where returning a mutable item from const parameters allows the compiler to assume the return value is unique.

-Steve

Reply via email to