[Top][All Lists]

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

Re: The poor state of documentation of pcase like things.

From: Michael Heerdegen
Subject: Re: The poor state of documentation of pcase like things.
Date: Sun, 03 Jan 2016 06:17:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Drew Adams <address@hidden> writes:

> > pcase is not only useful when destructuring is involved (though
> > it is the most important feature).
> I disagree.  I think it is only useful when destructuring is
> involved.  If it is just doing literal pattern-matching then
> it offers nothing more than does `cl-case'.

Well, there are some more pattern types available, and you can all
combine them.

> (Unless it lets you change the equality predicate (does it?).

No, but you can just use (pred (my-eq thing)) as pattern.  That would
test whether `thing' is `my-eq' to the object.

> > The often cited case of a long list of conditions that only tests
> > for equality for a longer list of symbols is a good example,
> I don't know what example you mean.  Do you mean testing
> for equality against more than one symbol, as in multiple
> `cl-case's?  Or testing the same symbol value more than once
> (just use a `let')?

I was talking about Lars' example.

> The same would be true of a let construct that only destructures
> (e.g., `destructuring-bind').

destructuring-bind is much less powerful than pcase.  pcase can test
whether something matches, combined with condition testing, boolean
operations and local variable binding.  There are cases where it's worth
it to prefer pcase over other tools where no destr-bind is involved.
But that's a minority of cases, yes.


reply via email to

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