[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incompatibility with pattern matching



On Tue, 20 Sep 2005, Michael Sperber wrote:

Andre van Tonder <andre@xxxxxxxxxxxxxxxxx> writes:

It seems that the constructor paradigm chosen in the draft does not easily
accommodate future extensions for pattern matching.  The problem is that a
constructor can be many to one.  E.g., in

  (define-type foo (x y)
    (fields a immutable (+ x y)))

we cannot automatically generate a pattern that can be used (like in MzScheme):

  (match (make-foo 1 2)
   ((make-foo x y) .....))

This is true as far as pattern matching by position is concerned.  I
personally think this is a good thing, as pattern matching by position
scales very poorly.


I agree that it scales poorly, but the same objection arguably applies to /constructors/ (and parents) with positional arguments, yet these are built into the basic syntax.

Cheers
Andre