When should pure function modify parameters?

Brother Bill brotherbill at mail.com
Mon Nov 17 14:46:06 UTC 2025


Pure functions in Functional Programming provide the same result 
when provided the same arguments.

They are not allowed to read or write to system resources such as 
file system, console, clock, network, etc.  In addition, they may 
not read/write to module level variables.

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.

Also, would you agree that not mutating parameters to have "true" 
purity would be preferred?


More information about the Digitalmars-d-learn mailing list