Re: Does ANSI Common Lisp have pattern matching?



Andy Freeman wrote:
On May 5, 11:16 am, Jon Harrop <j...@xxxxxxxxxxxxxxxxx> wrote:
And all benefit from a useful core pattern matcher.

What happens if that core is more powerful (read expensive) than what I
need?

You don't use all of its features.

If it is less powerful, then what?

You must combine pattern matching with other approaches (which is exactly
what you already do) or extend the matcher using macros (OCaml) or active
patterns (F#).

What if its token syntax doesn't match my needs?

Change the syntax to whatever you want.

Oops - that "core pattern matcher" just became a constraint.

How so?

Lisp actually has lots of pattern matchers.

None are as common as any of the other FPLs with pattern matching built in.

And, unlike other languages, rolling your own is painless enough that not
using one isn't a huge problem.

Greenspun. The pattern matchers in Haskell, OCaml, F# and Mathematica
compilers are thousands of lines of code each. Pattern matching algorithms
remain an active area of research.

However, the basic fact remains - Harrop doesn't like Lisp.

What if Common Lisp lacked mapcar? Would you say, "hey, no problem. Everyone
can implement their own and introduce unnecessary quirks and
incompatibilities."? Would you say, "there are thousands of mapcar
implementations out there, which is much better than having a single
widely-adopted standard."?

The fact is, pattern matching is more common that mapcar. It is ubiquitous
in languages that support it. I think that warrants putting a standard
pattern matcher in the next version of Lisp.

--
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet
.