Gabriel Dos Reis <gdr@integrable-solutions.net> virkkoi:> Joachim Durchholz <joachim.durchholz@web.de> writes:
[On pattern matching]> | Though it's beyond me why this never made it into mainstream imperative> | languages; it's exceedingly useful.>> Probably because people have been using the more general Visitor Pattern?

The more excruciatingly painful, you mean?

I once participated in writing a toy OQL compiler. The implementation
language was preordained to be C++. We did things by the book and used
the visitor pattern instead of "ugly" dynamic casts to discriminate
between different syntactic classes.

It was horrible, really. Having to write a trivial visit-method in
every class, and having to write all the auxiliary visitor classes
whenever the syntax tree had to be traversed. I couldn't help thinking
all the time how much simpler everything would have been had we just
used Haskell, defined a simple datatype for the abstract syntax, and
pattern matched on the terms.