On 8/16/12 10:26 PM, Nathan wrote:
> 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.
>
> Another is to change the specific match syntax so you say something like:
>
> match myfoo {
> discriminator bar => /* yes, this is a klunky new keyword, so I
> don't recommend this in practice, but it makes the point. */
> bar => /* bare identifiers are always bindings. */
> }fwiw, OCaml does match myfoo with | #bar -> (*any item of sum type bar*) | `bar -> (*sum constructor `bar*) | bar -> (*binding*) It works nicely in practice. Cheers, David -- David Rajchenbach-Teller, PhD Performance Team, Mozilla
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
