DEV Community

Discussion on: Should function arguments be reassignable or mutable?

Collapse
 
martinhaeusler profile image
Martin Häusler • Edited

Function parameters should never be re-assignable from within the function. It's just unclean. If the language allows you to assign a default value in case of the absence of a parameter, that's fine, but once the function context opens and the first statement is placed, they should be locked down tight. Don't give people needless room for error.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I think I've been thoroughly convinced this is the right direction.

It still leaves open how to handle argument sanitization, or prep-work. But I think that can be handled by convention, either by hiding, or different variable names.