Page MenuHomePhabricator

Should function arguments be assignable or mutable?
Closed, ResolvedPublic

Asked by jcmcdonald on Jan 1 2018, 12:34 PM.

Details

There's an interesting discussion on dev.to() about whether function arguments should be mutable. I think this topic bears consideration in Ratscript.

Answers

jcmcdonald
Updated 1,974 Days Ago

I think I agree with the article's assertion: function arguments should be immutable by default, unless explicitly marked otherwise. I believe this will prevent mistakes from functions modifying their inputs directly.

nisstyre56
Updated 1,165 Days Ago

I don't think it's relevant if you consider arguments as variable assignment. Then just do whatever the rest of the language does with variables. If they're immutable, then they're immutable, if not, then you should be able to assign to them using whatever scope rules you have. See https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_value for an explanation of how languages like C and Scheme do it.

New Answer

Answer

This question has been marked as closed, but you can still leave a new answer.