From: Alan Mackenzie <acm@muc.de>
To: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: cond* with bug fixed.
Date: Mon, 29 Jan 2024 20:04:51 +0000 [thread overview]
Message-ID: <ZbgE46fMZKvun9mA@ACM> (raw)
In-Reply-To: <E1rUSSB-00030X-4B@fencepost.gnu.org>
Hello, Richard.
On Mon, Jan 29, 2024 at 09:17:39 -0500, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> I found the spurious comma in no time after adding a feature to
> the byte compiler to warn about spurious calls to comma.
> Here's the fixed version of cond-star.el.
[ .... ]
I proof read it, and there were typos in the doc strings and comments.
Also, in the doc string for match*, there's a reference to
COND*-EXPENDER with no text explaining it. Should this perhaps be
cond*-expAnder? Or is it for a syntactic element which is no longer in
cond*? I've put a FIXME!!! into the text at this place.
I've included a patch for all the above corrections.
Also the "\\>" concatenated onto regular expressions in two places,
meaning "end of the text to be matched" which we discussed before,
should really be "\\'", as pointed out by Andreas Schwab this morning.
I've included corrections for these in the patch, (which I hope are
correct).
Also I'm very impressed by the clarity of the comments and doc strings.
Thanks for putting the effort into these. They should make using cond*
and future maintenance much easier than it would otherwise have been.
I believe the question of how to commit the new file to the git
repository is still open. As Eli noted this morning, I'm willing (and
indeed eager) to lend my services for the creation and maintenance of a
git branch, should the decision fall that way (and even if it doesn't).
I think it would be good to commit cond-star.el soon.
Here's the patch:
--- stallman.20240129.el 2024-01-29 18:51:38.182384122 +0000
+++ stallman.20240129b.el 2024-01-29 19:48:00.309197752 +0000
@@ -24,8 +24,8 @@
(defmacro cond* (&rest clauses)
"Extended form of traditional Lisp `cond' construct.
-A `ond*' construct is a series of clauses, and a clause
-normally has the form (CONDITION BDOY...).
+A `cond*' construct is a series of clauses, and a clause
+normally has the form (CONDITION BODY...).
CONDITION can be a Lisp expression, as in `cond'.
Or it can be `(bind* BINDINGS...)' or `(match* PATTERN DATUM)'.
@@ -36,18 +36,18 @@
unconditionally for whatever scope they cover.
`(match* PATTERN DATUM)' means to match DATUM against the pattern PATTERN
-The condition counts as teue if PATTERN matches DATUM.
+The condition counts as true if PATTERN matches DATUM.
-Mon=exit clause:
+Non-exit clause:
If a clause has only one element, or if its first element is
-t, or if it starts or ends with the keyword :nn-exit, then
+t, or if it starts or ends with the keyword :non-exit, then
this clause never exits the `cond*' construct. Instead,
control falls through to the next clause (if any).
The bindings made for the BODY of the clause are made again
for the rest of the clauses in this `cond*' construct.
-\\[match*\\] for documention of the patterns for use in `match*'."
+\\[match*\\] for documentation of the patterns for use in `match*'."
(cond*-convert clauses))
(defmacro match* (pattern datum)
@@ -55,13 +55,13 @@
It is not really a LIsp function, and it is meaningful
only in the CONDITION of a `cond*' clause.
-`_' matvhes any value.
+`_' matches any value.
KEYWORD matches that keyword.
nil matches nil.
t matches t.
SYMBOL matches any value and binds SYMBOL to that value.
If SYMBOL has been matched and bound earlier in this pattern,
- it matches here the same value that it mached before.
+ it matches here the same value that it matched before.
REGEXP matches a string if REGEXP matches it.
The match must cover the entire string from its first char to its last.
ATOM (meaning any other kind of non-list not described above)
@@ -70,7 +70,7 @@
as in the function `rx', and matches the data that way.
(rx REGEXP SYM0 SYM1...) uses a regexp specified in s-expression form,
and binds the symbols SYM0, SYM1, and so on
- to (match-string 0 DATUN), (match-string 1 DATUM), and so on.
+ to (match-string 0 DATUM), (match-string 1 DATUM), and so on.
You can use as many SYMs as regexp matching supports.
`OBJECT matches any value `equal' to OBJECT.
@@ -89,14 +89,16 @@
Strict checking is the default.
(cdr-safe PATTERN) matches PATTERN with lax checking of cdrs.
That means that `list' patterns do not examine the final cdr.
-(and CONJUNCTS...) matches each of te CONJUNCTS against the same data.
+(and CONJUNCTS...) matches each of the CONJUNCTS against the same data.
If all of them match, this pattern succeeds.
If one CONJUNCT fails, this pattern fails and does not try more CONJUNCTS.
-(or DISJUNCTS...) matches each of te DISJUNCTS against the same data.
- If all of them match, this pattern matches.
+(or DISJUNCTS...) matches each of the DISJUNCTS against the same data.
+ If any of them match, this pattern matches.
If one DISJUNCT succeeds, this pattern succeeds
- and does not try more DISJUNCT.
+ and does not try more DISJUNCTS.
(COND*-EXPENDER ...)
+ FIXME!!! Text appears to be missing here, ACM, 2024-01-27. Should that be
+ cond*-expAnder, perhaps?
(PREDICATE SYMBOL)
matches datum if (PREDICATE DATUM) is true,
then binds SYMBOL to DATUM.
@@ -186,7 +188,7 @@
this one could have exited but does not exit.
This is used for conditional exit clauses."
(if (and uncondit-clauses rest)
- (error "Clase is both exiting and non-exit"))
+ (error "Clause is both exiting and non-exit"))
(let ((pat-type (car-safe condition)))
(cond ((eq pat-type 'bind*)
(let* ((bindings (cdr condition))
@@ -345,15 +347,15 @@
;;; ??? Probably should optimize the `nth' calls in handling `list'.
(defun cond*-subpat (subpat cdr-ignore bindings inside-or backtrack-aliases data)
- "Generate code to match ibe subpattern within `match*'.
+ "Generate code to match the subpattern within `match*'.
SUBPAT is the subpattern to handle.
CDR-IGNORE if true means don't verify there are no extra elts in a list.
BINDINGS is the list of bindings made by
the containing and previous subpatterns of this pattern.
-Each element of BINDINGS must have the frm (VAR VALUE).
+Each element of BINDINGS must have the form (VAR VALUE).
BACKTRACK-ALIASES is used to pass data upward. Initial call should
pass (list). The cdr of this collects backtracking aliases made for
-variables boung within (or...) patterns so that the caller
+variables bound within (or...) patterns so that the caller
can bind them etc. Each of them has the form (USER-SYMBOL . GENSYM).
DATA is the expression for the data that this subpattern is
supposed to match against.
@@ -409,7 +411,7 @@
(cons bindings `(eql ,subpat ,data)))
;; Regular expressions as strings.
((stringp subpat)
- (cons bindings `(string-match ,(concat subpat "\\>") ,data)))
+ (cons bindings `(string-match ,(concat subpat "\\'") ,data)))
;; All other atoms match with `equal'.
((not (consp subpat))
(cons bindings `(equal ,subpat ,data)))
@@ -418,7 +420,7 @@
;; Regular expressions specified as list structure.
;; (rx REGEXP VARS...)
((eq (car subpat) 'rx)
- (let* ((rxpat (concat (rx-to-string (cadr subpat) t) "\\>"))
+ (let* ((rxpat (concat (rx-to-string (cadr subpat) t) "\\'"))
(vars (cddr subpat)) setqs (varnum 0)
(match-exp `(string-match ,rxpat ,data)))
(if (null vars)
@@ -469,7 +471,7 @@
expressions)
(setq i (1+ i))
(push (cdr result) expressions)))
- ;; Verify that list ends here, if we are suppose to check that.
+ ;; Verify that list ends here, if we are supposed to check that.
(unless cdr-ignore
(push `(null (nthcdr ,i ,data)) expressions))
(cons bindings (cond*-and (nreverse expressions)))))
@@ -516,7 +518,7 @@
;; Handle disjunction subpatterns.
((eq (car subpat) 'or)
;; The main complexity is unsetting the pattern variables
- ;; that tentatively matches in an or-branch that later failed.
+ ;; that tentatively match in an or-branch that later failed.
(let (expressions
(bindings-before-or bindings)
(aliases-before-or (cdr backtrack-aliases)))
@@ -592,7 +594,7 @@
;; Process VAR to get a binding for it.
(let ((result (cond*-subpat (cadr subpat) cdr-ignore bindings inside-or backtrack-aliases data)))
(cons (car result)
- ;; This is the test condition
+ ;; This is the test condition.
(cond*-bind-around (car result) (nth 2 subpat)))))
(t
(byte-compile-warn-x subpat "Undefined pattern type `%s' in `cond*'" (car subpat)))))
@@ -642,7 +644,7 @@
(car conjuncts)
`(and . ,conjuncts))))
-;; Convert the arguments in a form that calls `backuotelist*'
+;; Convert the arguments in a form that calls `backquote-list*'
;; into equivalent args to pass to `list'.
;; We assume the last argument has the form 'LIST.
;; That means quotify each of that list's elements,
> --
> Dr Richard Stallman (https://stallman.org)
> Chief GNUisance of the GNU Project (https://gnu.org)
> Founder, Free Software Foundation (https://fsf.org)
> Internet Hall-of-Famer (https://internethalloffame.org)
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2024-01-29 20:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-29 14:17 cond* with bug fixed Richard Stallman
2024-01-29 20:04 ` Alan Mackenzie [this message]
2024-02-01 3:49 ` Richard Stallman
2024-02-01 7:45 ` Eli Zaretskii
2024-02-04 4:44 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZbgE46fMZKvun9mA@ACM \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.