[Openmcl-devel] matching patterns

Greg Pfeil greg at clozure.com
Wed Oct 3 13:54:56 PDT 2012


On 3 Oct 2012, at 14:27, Taoufik Dachraoui <dachraoui.taoufik at gmail.com> wrote:

> I understand your skepticism about accepting match into CCL, but we can consider cond as
> a general and portable stuff. Many languages have a pattern matching built into the language.
> I believe it is very useful and it is deplorable (for me at least) that there is no pattern matching 
> built into CCL that is very efficient

It's not skepticism. COND is part of Common Lisp the language. Your MATCH is not. There is a specification that says what a Common Lisp implementation must do. Certain other things (threads, FFI, etc.) that are difficult or impossible to provide as libraries are generally added to implementations as well.

However, there is no reason an efficient pattern matching construct can not be built as a library and shared among all Common Lisp implementations. This is better for everyone. The user does not have to worry that SBCL's pattern matching is different from CCL's pattern matching and conditionalize their code to use the appropriate one. The pattern-match developer does not have to worry about keeping the version built into each implementation up-to-date. The compiler developer does not have to worry about maintaining more code as part of their system. And everyone gets the benefit of the single library being used by many more people than it would if it were part of a single implementation, meaning bugs get found and the code improves faster.

It is a simple matter of modularity. In fact, I would go so far as to say that the CL spec is already too big and much of it could be pulled out into a standard library – but good luck convening a committee to standardize Common Lisp v2, either to pull out a standard library or to add pattern matching.

> I think the match I wrote is concise and it looks beautiful (I do not know about the implementation), 
> it remains to see if it is as I see it, that is why I wanted to contribute the code and see how it can be 
> viewed by experts; if I was a CCL expert I would hack it and add match to the language, but 
> unfortunately I am not.

Adding MATCH to CCL would not add it to the language. The language is CCL, you would merely be adding it to a single implementation, which would hinder adoption, as many people try to write code that does not depend on a particular implementation. Even though I use CCL pretty much exclusively, I would choose Fare-matcher over yours simply because it works across CL implementations, even if yours is much faster, etc.

I am not calling into question the quality of your code. But the best way to get it seen and used by the most people is to publish a library and add it to Quicklisp.


More information about the Openmcl-devel mailing list