[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase defuns
From: |
LdBeth |
Subject: |
Re: pcase defuns |
Date: |
Wed, 22 Dec 2021 22:07:52 +0800 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-apple-darwin18.7.0) MULE/6.0 (HANACHIRUSATO) |
>>>>> In <871r299e5j.fsf@gnu.org>
>>>>> Tassilo Horn <tsdh@gnu.org> wrote:
Tassilo> Andrew Hyatt <ahyatt@gmail.com> writes:
Tassilo> Hi Andrew,
> As a part of a personal project, I wrote a way to define functions in
> an equivalent way to pcases. For example:
>
> (pcase-defun mytest (a b _)
> "Match on 'a 'b with the third argument a wildcard"
> "a b match")
>
> (pcase-defun mytest (c ,var _)
> "Match on 'c binding VAR, with the third argument a wildcard"
> (format "c %s match" var) )
>
> (mytest 'a 'b 'c) -> "a b match"
> (mytest 'c 100 'c) -> "c 100 match"
Tassilo> So that's basically similar to cl-defgeneric / cl-defmethod just with
Tassilo> pcase pattern matching, right?
That reminds me of an old tiny piece of Common Lisp code from CMU AI
Repository that implements single inheritance message passing OOP,
which could be easily ported to Emacs Lisp.
--
LDB
boops.lisp
Description: Text document
- pcase defuns, Andrew Hyatt, 2021/12/18
- Re: pcase defuns,
LdBeth <=
Re: pcase defuns, Stefan Monnier, 2021/12/19
- Re: pcase defuns, Andrew Hyatt, 2021/12/19
- Re: pcase defuns, Richard Stallman, 2021/12/20
- Re: pcase defuns, Andrew Hyatt, 2021/12/21
- Re: pcase defuns, Richard Stallman, 2021/12/21
- Re: pcase defuns, Andrew Hyatt, 2021/12/22
- Re: pcase defuns, Richard Stallman, 2021/12/23
Re: pcase defuns, Stefan Monnier, 2021/12/21
Re: pcase defuns, Richard Stallman, 2021/12/19
Re: pcase defuns, Po Lu, 2021/12/22