[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cond*
|
From: |
Ihor Radchenko |
|
Subject: |
Re: cond* |
|
Date: |
Mon, 08 Jan 2024 15:35:24 +0000 |
Richard Stallman <rms@gnu.org> writes:
> > > Since the idea is pattern-matching, I think that a regexp is natural
> > > as well as more general. Why not do this?
>
> > It is not very clear then how to match plain strings for equality.
>
> 1. Instead of writing the string as a literal, write a regexp to match
> only that string. This is not hard.
This is a bad idea when writing _generic purpose_ code - regexp matching
is _a lot_ slower compared to string comparison. Orders of magnitude.
> 2. Use this constrained variable patern:
>
> (equal foo "xyz")
>
> It will bind the variable `foo', but you are not required to use it.
I am not a big fan of introducing yet another convention:
Compare
(cond*
((match* `("foo?" "bar") '("fo" "bar")) t)) ; => t
(pcase '("fo" "bar")
(`("foo?" "bar") t)) ; => nil
People familiar with `pcase' will have to keep the above distinction in
mind all the time - a source of potential confusion.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
- Re: cond*, (continued)
- Re: cond*, Richard Stallman, 2024/01/05
- Re: cond*, Ihor Radchenko, 2024/01/06
- Re: cond*, Richard Stallman, 2024/01/07
- Re: cond*, Ihor Radchenko, 2024/01/08
- Re: cond*, Richard Stallman, 2024/01/26
Re: cond*, Richard Stallman, 2024/01/02
- Re: cond*, Ihor Radchenko, 2024/01/03
- Re: cond*, Richard Stallman, 2024/01/05
- Re: cond*, Ihor Radchenko, 2024/01/06
- Re: cond*, Richard Stallman, 2024/01/07
- Re: cond*,
Ihor Radchenko <=