[bitc-dev] Issue with binding patterns

Jonathan S. Shapiro shap at eros-os.org
Mon Aug 29 14:47:51 EDT 2005

Swaroop noticed a syntactic ambiguity the other day. Consider:

  (defunion (list 'a) nil (cons 'a (list 'a)))

  (define (f nil) ...)

Note that the binding pattern in F shadows nil. As long as we know this
is a binding pattern, this creates no ambiguity. However, now consider:

  (defunion (list 'a) nil (cons 'a (list 'a)))

  (define (f x)
    (case (x)   ; value pattern match
          ((nil ...)

There is an ambiguity here: does NIL match a value, or should it be
treated as an identifier? If it is treated as an identifier, we become
unable to match arity zero constructors.

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?


More information about the bitc-dev mailing list