The default arg convention for function args, for
loops, and with
statements is read
.
The default arg convention for variable declarations is var
.
I think this is a good opportunity review and decide if the default arg convention for variable declarations should also be read
.
The advantages of using read
for variable declarations include:
- Better performance by default,
read
is a reference and will not make copies, you can easily find all copies by searching forvar
. - Single argument convention used for everything, improving language consistency and simplicity.
- When the user wants to mutate the variable, making him specify explicitly whether he wants to mutate an owned copy (var) or to mutate the reference (ref). This will prevent mistakes of accidentally mutating the copy and not the original variable, or unintentionally making copies.
- I think immutability by default is considered good practice.
- since mojo can report unused variables and unused mutations, it is less of a concern to require an explicit keyword for variable declarations.
Maybe it would be interesting to gather a statistic somehow of which convention in theory will be used more often.