When should pure function modify parameters?

user1234 user1234 at 12.de
Wed Nov 19 13:05:52 UTC 2025


On Wednesday, 19 November 2025 at 11:31:25 UTC, Guillaume Piolat 
wrote:
> On Monday, 17 November 2025 at 14:46:06 UTC, Brother Bill wrote:
>> In D, they are allowed to mutate parameters which seems to 
>> violate purity.  Why did D make this choice and when to best 
>> exploit this architectural decision.
>
> It only violate purity in the sense of how other language 
> define it, but it makes a lot of sense to be allowed to mutate.
>
> "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.
> Then constructs that could be all pure end up not being marked 
> pure.

Isn't that because of the side effect on error ?

(https://www.felixcloutier.com/x86/fpatan#fpu-flags-affected)


More information about the Digitalmars-d-learn mailing list