On 8/16/12 1:26 PM, Nathan wrote:
The solution I'm proposing is to alter the grammar so that it's
possible by looking at only the pattern matching text, without knowing
any other context whether it is a discriminator match or a new
binding. There are at least two ways to do this:
One is to ensure that it's always possible when looking at an
identifier in *any* context whether or not it is a discriminator or a
binding/reference. Haskell does this elegantly, IMO, by forcing
discriminators to start with upper case and bindings/references to
start with lower case. Any other rule that prevents the identifiers
from overlapping is sufficient. I prefer this approach because it
solves the ambiguity problem for *every* grammar production which
involves either a reference/binding *or* an enum discriminator.
We used to require a ? before variable bindings, but it was very noisy
in practice. It also caused bugs, because people would not write ? and
things would sometimes compile. I'm personally very reluctant to go back
to that world.
I would like to try emitting a warning if the capitalization doesn't
match up. (I'm actually OK with an error too, but we have so far avoided
case sensitivity everywhere in the language and that's a nice property
to have for e.g. interoperability with C code.)
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev