emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: Nikita Domnitskii
Subject: Re: Instead of pcase
Date: Tue, 28 Nov 2023 12:35:26 +0600

Richard Stallman <rms@gnu.org> writes:

>   (cond* (:bind b1 (b (save-window-excursion (find-file-at-point filename))))
>          ((bufferp b) (setq b1 b))
>          ((bufferp (car-safe b)) (setq b1 (car-safe b))))
>   (if b1 (switch-to-buffer-other-window b)))
>
>   (cond* (:bind b1 (b (save-window-excursion (find-file-at-point filename))))
>          ((bufferp b) (switch-to-buffer-other-window b))
>          ((bufferp (car-safe b)) (switch-to-buffer-other-window (car-safe 
> b)))))
>
>   (let ((b (save-window-excursion (find-file-at-point filename))) b1)
>     (if (or (match-set b1 b (bufferp b1))
>             (match-set b1 (car-safe b) (bufferp b1)))
>         (switch-to-buffer-other-window b1)))

To be honest all variants look less expressive than original
pcase.

Maybe instead of trying to implement cond* we should look into impoving
pcase patterns? As a starting point I suggest Racket pattern matching
implementation (which in my opinion is fairly readable):
https://docs.racket-lang.org/reference/match.html

-- 
Best Regards,
Nikita Domnitskii



reply via email to

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