Re: pattern-matching in LISP?



Andy Freeman wrote:
On May 12, 10:24 am, Jon Harrop <j...@xxxxxxxxxxxxxxxxx> wrote:
let f(a, (b, c)) = ((a, b), c);;

(defun f (v) (cons (cons (car v) (cadr v)) (cddr v)))

http://www.lisp.org/HyperSpec/Body/mac_destructuring-bind.html

That would be even longer and just as unnecessarily obfuscated.

No. Lisp predates ML by a long way and lacks most of its features,
including pattern matching.

Wrong.

As you can see, you won't get a useful response if you ask Lispers about any
of the language features that they don't use. Best case, you'll get an
ad-hoc, informally-specified and bug-ridden implementation of half of an ML
pattern matcher.

Anyone wanting to learn about ML-style pattern matching would be much better
off asking in a group related to any language that integrates a decent
pattern matcher (Standard ML, F#, OCaml, Haskell etc.) and not Lisp, or by
reading introductory material:

http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html?cll
http://www.ffconsultancy.com/products/ocaml_journal/free/introduction.html?cll
http://www.ffconsultancy.com/ocaml/benefits/pattern_matching.html?cll
http://www.ffconsultancy.com/ocaml/benefits/parsing.html?cll
http://www.ffconsultancy.com/ocaml/benefits/symbolic.html?cll
http://www.ffconsultancy.com/ocaml/benefits/interpreter.html?cll

Folks who want to work the ML way are free to do so.

By using ML, yes.

To make an informed choice of language, you need to know the differences
between the languages. RB-tree rebalancing and symbolic rewriting are two
examples where languages with integrated pattern matching excel compared to
Lisp, both in terms of clarity and performance.

If you want to show Lisp in a good light, do not mention pattern matching.

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?usenet
.



Relevant Pages

  • Re: SBCL is now faster than Java, as fast as Ocaml, and getting better
    ... From which it is clearly impossible to decipher a working program. ... make Lisp look less stupid. ... But that is a MLish language. ... You are not seeing pattern matching popping up in Java 7. ...
    (comp.lang.lisp)
  • Unlearning Pattern Matching
    ... pattern matching is EASY in Lisp! ... It's almost hard to believe a language can be ... patrn a b c)) ...
    (comp.lang.lisp)
  • Re: Unlearning Pattern Matching
    ... It's almost hard to believe a language can be ... This ML-style pattern matcher ... takes just a few hours to write, even less for a real Lisp guru. ... Obviously you haven't read Dijkstra's PATTERN MATCHING considered ...
    (comp.lang.lisp)
  • Re: SBCL is now faster than Java, as fast as Ocaml, and getting better
    ... amount to learn from Mathematica because it addressed so many of Lisp's ... What do you think Mathematica can learn from Lisp? ... are overestimating the "language merits" of Mathematica as far as its ... go beyond our discussion of Lisp, MLish and pattern matching. ...
    (comp.lang.lisp)
  • Re: Flamebait if I ever saw it
    ... ML-style pattern matching its speed and static checking. ... you can't even implement a basic ML-style pattern matcher. ... Common Lisp fans explicitly and consciously reject the choice to ... | Add of expr * expr ...
    (comp.lang.lisp)