I would really like to advocate once again for Standard ML's solution: simply disambiguate variable bindings and tag constructors at the name resolution phase. It does mean that you can't have a variable with the same name as a tag constructor, and I know that there are a lot of fears that it would be confusing and lead to subtle bugs, but I've never heard of a case when a Standard ML programmer was confused. In my experience, few Standard ML programmers even know the rule exists.
What *does* lead to confusion and subtle bugs is accidentally using a variable binding instead of a nullary tag, or vice versa. Using a variable binding instead of a nullary tag is somewhat worse than using a nullary tag instead of a variable binding, because the typechecker will be more likely to catch the mistake. Experience suggests that the current regime leads to the worst outcome far more often than the Standard ML rule does, simply because it's easy to forget to add the dot and that leads to the compiler doing the wrong thing, and the typechecker won't catch it. Conversely, the Standard ML rule makes the compiler attempt to do the right thing by default. The only way it can go wrong (which I've never seen in practice) results in the nullary tag interpretation, which is an error that the typechecker has a good chance of catching. Thus the Standard ML solution has the nice properties of being both the most aesthetically pleasing and the most reliable solution to the prob lem. Patrick ----- Original Message ----- From: "Stefan Plantikow" <[email protected]> To: "Niko Matsakis" <[email protected]> Cc: [email protected] Sent: Wednesday, December 21, 2011 1:44:06 PM Subject: Re: [rust-dev] minor things that annoy you about Rust? Am 20.12.2011 um 19:16 schrieb Niko Matsakis: 3. Some way to deal with nullary tags in patterns. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
