[Top][All Lists]

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

Re: pcase-dolist

From: Tassilo Horn
Subject: Re: pcase-dolist
Date: Fri, 10 Jul 2015 16:44:42 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> Yes, if you want to pick the first two elements of a list with 2 or
>> more elements, you should use `(,w ,x . ,_).  I see that the above is
>> slightly more convenient and concise but I'd value consistency more.
> But that does not match the usual uses of "tuples represented as
> lists", where it's customary to use (A B) when the remaining fields
> are all nil (since (car nil) returns nil and (nth 5 '(1 2)) also
> returns nil rather than signaling an error) and where it's also
> customary to ignore any additional element.

Yes, but those don't have pcase in their name.  If that wouldn't be the
case with `pcase-let' I would not complain at all.

Hm, when you said that a better name for `pcase-dolist' was `dolist',
wouldn't `let(*)' be a better name for `pcase-let(*)', too?  It would be
very useful to be able to destructure in usual lets (like, e.g., in
Clojure).  I think there are gazillion of occurrences of

  (let* ((this-and-that (foo ...))
         (this (car this-and-that))
         (that (cdr this-and-that)))

AFAICS, the only thing that `pcase-let' is lacking is the ability to
introduce locals without providing a value, e.g.,

  (let ((x 1) b c) ...)

but that shouldn't be too hard to add, no?


reply via email to

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