[bitc-dev] Issue with binding patterns

Swaroop Sridhar swaroop at cs.jhu.edu
Mon Aug 29 15:21:35 EDT 2005


Jonathan S. Shapiro wrote:
> Swaroop noticed a syntactic ambiguity the other day. Consider:
> At present, we have a hack in place: identifiers bound by a value
> pattern may not shadow constructors, and this is considered to be a
> constructor constant match.
> 
> Does this seem reasonable?
> How do similar languages handle this?
Similarly.

Consider:
[swaroop at srl ~]$ ocaml
         Objective Caml version 3.08.3

# type 'a list = Nil | Cons of 'a * 'a list;;
type 'a list = Nil | Cons of 'a * 'a list

# let alist = Nil;;
val alist : 'a list = Nil

# match alist with Nil -> false | Cons(_, _) -> true;;
- : bool = false

(* To be really sure, check return type in the following
     example *)

# let blist = Cons(1, Nil);;
val blist : int list = Cons (1, Nil)

# match blist with Nil -> Nil |
                    Cons(_, _) -> Nil;;
- : 'a list = Nil


Swaroop.


More information about the bitc-dev mailing list