[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20268: 25.0.50; pcase-lambda broken
From: |
Stefan Monnier |
Subject: |
bug#20268: 25.0.50; pcase-lambda broken |
Date: |
Wed, 08 Apr 2015 15:25:36 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> Why not raise an error instead if there is no match
That would be an acceptable semantics, yes. I happen to dislike it
because of the performance cost, where in most use-cases you know the
pattern will match and just want to replace a bunch of car/cdr/aref with
a single pattern.
I.e. the code you'd have written without pcase-let would have been
(let ((a (foo))
(b (car foo))
(c (nth 2 foo)))
which would naturally turn into a pattern like `(,b ,_ ,c)
but if you want to signal an error when the pattern fails to match, then
you get 3 additional consp tests plus a null test, at which point the
performance impact can become noticeable. You can get rid of the null
test with a pattern like `(,b ,_ ,c . ,_) but you can't get rid of the
3 consp tests.
Stefan