On 11-12-23 11:34 AM, Patrick Walton wrote:
I do agree that the action-at-a-distance is a potential problem, but experience 
suggests that the Standard ML rule leads to the bad outcome less often than the 
other alternatives. At this point I've tried all four alternatives 
(variable-by-default, tag-by-default, case sensitivity, and the Standard ML 
rule) and in my experience the last two avoid mixups far more than the first 
two do.

If I'm not mistaken, the Standard ML rule makes it impossible to allow local 
variable matching in patterns, because you'd be unable to shadow local 
variables and I suspect we probably don't want to go down that road. But I'm 
okay with using guards for matching against local variables.

Yeah. One thing that concerns me about that is that it means we lose the ability to write rebind-the-variable functional-style code:

let x = foo(bleh);
let x = thing(x);
let x = other(x);
...

Personally I find this style ... cute enough, in languages where local mutation is syntactically clunky, but for us I think it's not super important to support. We can just re-assign to the same local; it's terrible form to be changing the type of a variable part way through a function anyways.

(I'm warming up to the concept of differentiating locally-mutable and locally-immutable variables using 'mut ...' and 'let ...' though)

-Graydon
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to