[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27659: 26.0.50; Add string-matched-text: string-match + match-string
From: |
Drew Adams |
Subject: |
bug#27659: 26.0.50; Add string-matched-text: string-match + match-string |
Date: |
Wed, 19 Jul 2017 17:54:28 -0700 (PDT) |
> (when (string-match "[[:alpha:]]+-\\([0-9]+\\)" str)
> (match-string 1 str))
> is equivalent to:
> (string-matched-text "[[:alpha:]]+-\\([0-9]+\\)" str 1)
My own opinion, FWIW, is that the former is much clearer
and is sufficiently succinct. YAGNI.
[FWIW2:
I would write the former as
(and (string-match ...) (match-string...)), not as
(when (string-match ...) (match-string...)).
I follow the Common Lisp convention of using `when' to
indicate (to a human) that the return value is not
important (the function is used for side effects only).
I don't expect a human reader to look for a `nil' return
value from `when', for instance.]
bug#27659: 26.0.50; Add string-matched-text: string-match + match-string, Michael Heerdegen, 2017/07/21