When should pure function modify parameters?
Brother Bill
brotherbill at mail.com
Mon Nov 17 16:38:42 UTC 2025
On Monday, 17 November 2025 at 15:53:58 UTC, Lance Bachmeier
wrote:
> This is really bad for those of us that prefer functional
> programming, given that there's no way to mark a function
> actually pure - making it pure by the common use of the term is
> something you have to do manually on every function, and it's
> so much unnecessary boilerplate that I can't imagine someone
> doing it.
Yes, it is boilerplate. Making a parameter 'in' doesn't take
much typing.
I can imagine me doing it.
What I see is that in addition to the standard use of 'pure', D
gives you some leeway if you need it. I think I will start using
pure for the industry wide meaning, which is that you don't
mutate your parameters.
Using pure for ref parameters or to mutate parameters seems so
wrong.
Having an escape hatch to do logging seems right.
More information about the Digitalmars-d-learn
mailing list