It could very well be that, in practice, banning functions whoās name donāt end in ā!ā from modifying their arguments is too difficult to be sensible - I donāt know enough about Julia to tell (Iām new too). But Tamas_Pappās comment still made me want to express some thoughts.
I cannot rely on comments or (other) documentation being correct. I cannot rely on conventions being followed. I cannot rely on code being bug-free. But, barring bugs in the compiler, I can rely on rules of the language being followed. For instance, if a variable is declared const
, I can rely on it not being modified. Or, if a procedure argument in Fortran is declared INTENT(IN)
, I can rely on it not being modified by the procedure. (In C, declaring a pointer argument to a function as const
isnāt a guarantee, but gets you pretty close)
If I can declare what some code does or does not do, using language features rather than using comments or conventions, I strongly prefer that. Because comments can be wrong, and conventions can be broken, but language rules cannot. They can be relied upon. Itās nice not just for the user/reader of some code, but also for its writer, as it may catch bugs. What if I really didnāt intend to modify a function argument, but by mistake did anyway?
Obviously, there will always be uncertainty about what some unfamiliar code does, or whether your own code have bugs. But while less uncertainty isnāt as good as no uncertainty, it is still better than more uncertainty. Letās not refuse to reduce uncertainty just because we canāt eliminate it.
If there was a way of declaring āINTENTā for function arguments in Julia, be it with exclamation marks at the end of function names or through some other means, I think it would be nice. Not something I canāt live without, and if itās decided it isnāt worth the trouble, I can accept that, but still - it would be nice.