Dev from EU, currently working in frontend development, with knowledge of docker and kubernetes.
I love tinkering and staying up with the latest technology.
I don't think that the void return type has anything to to with function purity. A function can be pure even if it returns some value. It just shouldn't modify anything outside of it and does not use any variables that are defined outside of its scope. Its return value should be determined solely by its input parameters.
Dev from EU, currently working in frontend development, with knowledge of docker and kubernetes.
I love tinkering and staying up with the latest technology.
I don't think that the
void
return type has anything to to with function purity. A function can be pure even if it returns some value. It just shouldn't modify anything outside of it and does not use any variables that are defined outside of its scope. Its return value should be determined solely by its input parameters.Wouldn't that make any function in strongly typed languages "pure"?
No.
For example:
This function is not pure as it modifies
a
.