DEV Community

Discussion on: Should function arguments be reassignable or mutable?

Collapse
 
namirsab profile image
Namir • Edited

IMO,
Short answer: no,
Long answer: noooooooooooooooooooooooooooooooooooo,

I only do this on recursive functions in the internal implementation, as an output argument. And I document this as an exception so everybody knows that's not the default way to go, but it was necessary in that case.

EDIT:
UPS, after reading the post in detail, I saw you were asking about how to make the syntax easier in your language.

I'd just say default is not mutable, and if it mutates, i'd either mark it with out or mutable as you said. I always think of mutable arguments as output arguments, a way to give a function an "empty" box (with a "particular shape", if it's not a primitive value, like an instance of a class) that the function is gonna fill for me.