* bug#66863: [PATCH] Add two docstrings in cl-macs.el
@ 2023-10-31 22:36 Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-31 22:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-31 22:36 UTC (permalink / raw)
To: 66863, monnier
[-- Attachment #1: Type: text/plain, Size: 280 bytes --]
Tags: patch
Hi Emacs maintainers,
Here is a proposed patch with two docstrings added to cl-macs.el where
there were none previously. In particular, from previous changes, I
assume that Stefan you may be familiar with this area? I look forward
to your feedback.
Best
Jeremy
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-two-docstrings-in-cl-macs.el.patch --]
[-- Type: text/patch, Size: 1118 bytes --]
From 9a0d8649511377a160f410fd73f74558f4a8e9dc Mon Sep 17 00:00:00 2001
From: Jeremy Bryant <jb@jeremybryant.net>
Date: Tue, 31 Oct 2023 22:24:20 +0000
Subject: [PATCH] Add two docstrings in cl-macs.el
* lisp/emacs-lisp/cl-macs.el (cl--simple-exprs-p)
(cl--const-expr-p): Add docstrings.
---
lisp/emacs-lisp/cl-macs.el | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 43207ce7026..fd19bca60d9 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -101,6 +101,7 @@ cl--simple-expr-p
(and (> size 0) (1- size))))
(defun cl--simple-exprs-p (xs)
+ "Check if no side effects, and executes quickly, for each element of list XS."
(while (and xs (cl--simple-expr-p (car xs)))
(setq xs (cdr xs)))
(not xs))
@@ -118,6 +119,7 @@ cl--safe-expr-p
;;; Check if constant (i.e., no side effects or dependencies).
(defun cl--const-expr-p (x)
+ "Check if X is constant (i.e., no side effects or dependencies)."
(cond ((consp x)
(or (eq (car x) 'quote)
(and (memq (car x) '(function cl-function))
--
2.40.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#66863: [PATCH] Add two docstrings in cl-macs.el
2023-10-31 22:36 bug#66863: [PATCH] Add two docstrings in cl-macs.el Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-31 22:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-31 23:40 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-31 22:58 UTC (permalink / raw)
To: Jeremy Bryant; +Cc: 66863
> * lisp/emacs-lisp/cl-macs.el (cl--simple-exprs-p)
> (cl--const-expr-p): Add docstrings.
Hmm... tackling some tricky ones, eh?
> (defun cl--simple-exprs-p (xs)
> + "Check if no side effects, and executes quickly, for each element of list XS."
> (while (and xs (cl--simple-expr-p (car xs)))
> (setq xs (cdr xs)))
> (not xs))
I think I'd use a ref to `cl--simple-expr-p`, so we don't duplicate the
poorly defined "no side effects, and executes quickly".
Wait... `grep` says this function is not used any more, so maybe the
better option is to delete it.
> @@ -118,6 +119,7 @@ cl--safe-expr-p
>
> ;;; Check if constant (i.e., no side effects or dependencies).
> (defun cl--const-expr-p (x)
> + "Check if X is constant (i.e., no side effects or dependencies)."
> (cond ((consp x)
> (or (eq (car x) 'quote)
> (and (memq (car x) '(function cl-function))
Yeah..hmm.. by order of increasing preference:
- Move the comment to the docstring rather that just copying it.
- Clarify the difference with `macroexp-const-p`.
- Declare the function obsoleted by `macroexp-const-p`.
- Delete the function altogether.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#66863: [PATCH] Add two docstrings in cl-macs.el
2023-10-31 22:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-31 23:40 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-01 12:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-31 23:40 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 66863
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Add-two-docstrings-in-cl-macs.el.patch --]
[-- Type: text/x-diff, Size: 1274 bytes --]
From 16298965905b1859aa8a342b98803f4abd6da3f0 Mon Sep 17 00:00:00 2001
From: Jeremy Bryant <jb@jeremybryant.net>
Date: Tue, 31 Oct 2023 23:37:10 +0000
Subject: [PATCH] Add two docstrings in cl-macs.el
* lisp/emacs-lisp/cl-macs.el (cl--simple-exprs-p)
(cl--const-expr-p): Add docstrings
---
lisp/emacs-lisp/cl-macs.el | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 43207ce7026..15b56d0e322 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -101,6 +101,7 @@ cl--simple-expr-p
(and (> size 0) (1- size))))
(defun cl--simple-exprs-p (xs)
+ "Map `cl--simple-expr-p' to each element of list XS."
(while (and xs (cl--simple-expr-p (car xs)))
(setq xs (cdr xs)))
(not xs))
@@ -116,8 +117,10 @@ cl--safe-expr-p
(while (and (setq x (cdr x)) (cl--safe-expr-p (car x))))
(null x)))))
-;;; Check if constant (i.e., no side effects or dependencies).
(defun cl--const-expr-p (x)
+ "Check if X is constant (i.e., no side effects or dependencies).
+
+See `macroexp-const-p' for similar functionality without cl-lib dependency."
(cond ((consp x)
(or (eq (car x) 'quote)
(and (memq (car x) '(function cl-function))
--
2.40.1
[-- Attachment #2: Type: text/plain, Size: 1509 bytes --]
Hi Stefan,
Revised patch attached and comments below
Kind regards
Jeremy Bryant
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> * lisp/emacs-lisp/cl-macs.el (cl--simple-exprs-p)
>> (cl--const-expr-p): Add docstrings.
>
> Hmm... tackling some tricky ones, eh?
Apparently yes!
>
>> (defun cl--simple-exprs-p (xs)
>> + "Check if no side effects, and executes quickly, for each element of list XS."
>> (while (and xs (cl--simple-expr-p (car xs)))
>> (setq xs (cdr xs)))
>> (not xs))
>
> I think I'd use a ref to `cl--simple-expr-p`, so we don't duplicate the
> poorly defined "no side effects, and executes quickly".
See revised patch which follows this advice
>
> Wait... `grep` says this function is not used any more, so maybe the
> better option is to delete it.
>
>> @@ -118,6 +119,7 @@ cl--safe-expr-p
>>
>> ;;; Check if constant (i.e., no side effects or dependencies).
>> (defun cl--const-expr-p (x)
>> + "Check if X is constant (i.e., no side effects or dependencies)."
>> (cond ((consp x)
>> (or (eq (car x) 'quote)
>> (and (memq (car x) '(function cl-function))
>
> Yeah..hmm.. by order of increasing preference:
> - Move the comment to the docstring rather that just copying it.
Done
> - Clarify the difference with `macroexp-const-p`.
Added reference to this with my interpretation of the difference (which
could need change or not)
> - Declare the function obsoleted by `macroexp-const-p`.
> - Delete the function altogether.
>
>
> Stefan
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#66863: [PATCH] Add two docstrings in cl-macs.el
2023-10-31 23:40 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-01 12:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 9:23 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-01 12:17 UTC (permalink / raw)
To: Jeremy Bryant; +Cc: 66863
> From 16298965905b1859aa8a342b98803f4abd6da3f0 Mon Sep 17 00:00:00 2001
> From: Jeremy Bryant <jb@jeremybryant.net>
> Date: Tue, 31 Oct 2023 23:37:10 +0000
> Subject: [PATCH] Add two docstrings in cl-macs.el
Thanks, pushed.
> (defun cl--simple-exprs-p (xs)
> + "Map `cl--simple-expr-p' to each element of list XS."
This doesn't say how the results of `cl--simple-expr-p` are combined,
it might even suggest they're returned as a list.
I think I would have said something like
"Like `cl--simple-expr-p' but for a list of expressions."
> (defun cl--const-expr-p (x)
> + "Check if X is constant (i.e., no side effects or dependencies).
> +
> +See `macroexp-const-p' for similar functionality without cl-lib dependency."
"Similar" fails to describe the difference :-(
[ Note, I can't blame you: I know the difference but I couldn't come up
with a useful description of it, that is, one that is easier to
understand than the code itself. FWIW I believe the difference is
a latent bug, which is partly why I'd like to delete the function :-) ]
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#66863: [PATCH] Add two docstrings in cl-macs.el
2023-11-01 12:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-04 9:23 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 10:41 ` Stefan Kangas
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-04 9:23 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 66863
Thank you, I've made a note on conventions. For this patch, as you have
pushed, does this mean this is closed?
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> From 16298965905b1859aa8a342b98803f4abd6da3f0 Mon Sep 17 00:00:00 2001
>> From: Jeremy Bryant <jb@jeremybryant.net>
>> Date: Tue, 31 Oct 2023 23:37:10 +0000
>> Subject: [PATCH] Add two docstrings in cl-macs.el
>
> Thanks, pushed.
>
>> (defun cl--simple-exprs-p (xs)
>> + "Map `cl--simple-expr-p' to each element of list XS."
>
> This doesn't say how the results of `cl--simple-expr-p` are combined,
> it might even suggest they're returned as a list.
> I think I would have said something like
>
> "Like `cl--simple-expr-p' but for a list of expressions."
>
>> (defun cl--const-expr-p (x)
>> + "Check if X is constant (i.e., no side effects or dependencies).
>> +
>> +See `macroexp-const-p' for similar functionality without cl-lib dependency."
>
> "Similar" fails to describe the difference :-(
> [ Note, I can't blame you: I know the difference but I couldn't come up
> with a useful description of it, that is, one that is easier to
> understand than the code itself. FWIW I believe the difference is
> a latent bug, which is partly why I'd like to delete the function :-) ]
>
>
> Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#66863: [PATCH] Add two docstrings in cl-macs.el
2023-11-04 9:23 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-04 10:41 ` Stefan Kangas
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2023-11-04 10:41 UTC (permalink / raw)
To: Jeremy Bryant, Stefan Monnier; +Cc: 66863-done
Jeremy Bryant via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:
> Thank you, I've made a note on conventions. For this patch, as you have
> pushed, does this mean this is closed?
I think so, yes. Now done.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-04 10:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-31 22:36 bug#66863: [PATCH] Add two docstrings in cl-macs.el Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-31 22:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-31 23:40 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-01 12:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 9:23 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-04 10:41 ` Stefan Kangas
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.