[Top][All Lists]

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

RE: emacs-25 1d4887a: Improve documentation of 'pcase'

From: Drew Adams
Subject: RE: emacs-25 1d4887a: Improve documentation of 'pcase'
Date: Mon, 25 Jan 2016 07:56:10 -0800 (PST)

> FWIW Drew mentioned that it maybe could be cool if the equivalence
> predicate could be specified locally for a pcase form like
> (pcase my-string #'string-collate-equalp ("Noël" "Christmas")) or so.

I didn't remember suggesting that, but I guess maybe you meant this:

   I think [pcase] is only useful when destructuring is
   involved.  If it is just doing literal pattern-matching
   then it offers nothing more than does `cl-case'.

   (Unless it lets you change the equality predicate (does it?).
   That's one thing that I wish `cl-case' (and Common lisp `case')
   would let you do: specify ... a comparer other than `eql'.)

Anyway, it's a good idea, but unlike the simple case of Common Lisp
`case', `pcase' uses multiple complex patterns, and they can involve

So in principle there could be a need to specify different equality
predicates for different patterns of the same `pcase', or even for
different parts of the same pattern.

Or maybe the different-parts-of-the-same-pattern problem could
be expressed in stages, i.e., by breaking a complex pattern into
multiple simpler patterns, each possibly with its own equality

When it comes to pattern matching, different equality predicates
can become important.  In Lisp, we have `eq', `equal', `eql', `=',
`string=', etc., and users can of course define their own.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]