When should pure function modify parameters?
Nick Treleaven
nick at geany.org
Wed Nov 19 13:03:54 UTC 2025
On Wednesday, 19 November 2025 at 11:31:25 UTC, Guillaume Piolat
wrote:
> "pure" is a nice idea, the problem start when you want to use
> it and a lot of stuff isn't actually marked pure, such as a lot
> of core.stdc.math:
>
> https://github.com/dlang/dmd/blob/master/druntime/src/core/stdc/math.d#L2968
>
> Why is atan2f not pure? I have no idea.
Maybe because it can set `errno` to `EDOM`, like `acos`:
> Domain error may occur if x and y are both zero.
https://cppreference.com/w/c/numeric/math/atan2.html#Error_handling
More information about the Digitalmars-d-learn
mailing list