unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
       [not found] ` <20220617171130.8EDECC01685@vcs2.savannah.gnu.org>
@ 2022-06-17 17:58   ` Stefan Monnier
  2022-06-17 18:01     ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2022-06-17 17:58 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Ingebrigtsen

>  (defalias 'byte-run--set-doc-string
>    #'(lambda (f _args pos)
>        (list 'function-put (list 'quote f)
> -            ''doc-string-elt (list 'quote pos))))
> +            ''doc-string-elt (if (numberp pos)
> +                                 pos
> +                               (list 'quote pos)))))

Should we push this one a step further, as below?

>  (defalias 'byte-run--set-indent
>    #'(lambda (f _args val)
>        (list 'function-put (list 'quote f)
> -            ''lisp-indent-function (list 'quote val))))
> +            ''lisp-indent-function (if (numberp val)
> +                                       val
> +                                     (list 'quote val)))))

Doing the same here would sadly break too much existing code.


        Stefan


diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index dd90bcf4d82..140a1d765d5 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -217,9 +217,7 @@ 'byte-run--set-doc-string
 (defalias 'byte-run--set-indent
   #'(lambda (f _args val)
       (list 'function-put (list 'quote f)
-            ''lisp-indent-function (if (numberp val)
-                                       val
-                                     (list 'quote val)))))
+            ''lisp-indent-function val))))
 
 (defalias 'byte-run--set-speed
   #'(lambda (f _args val)
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 200af057cd7..b1579a61fe5 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -545,7 +545,7 @@ cl-defmethod
 \(and can be extended) by the various methods of `cl-generic-generalizers'.
 
 \(fn NAME [EXTRA] [QUALIFIER] ARGS &rest [DOCSTRING] BODY)"
-  (declare (doc-string cl--defmethod-doc-pos) (indent defun)
+  (declare (doc-string #'cl--defmethod-doc-pos) (indent defun)
            (debug
             (&define                    ; this means we are defining something
              [&name [sexp   ;Allow (setf ...) additionally to symbols.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-17 17:58   ` master f515d658e5 1/2: Don't quote numbers in byte-run--set-* Stefan Monnier
@ 2022-06-17 18:01     ` Stefan Monnier
  2022-06-17 18:08       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2022-06-17 18:01 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Ingebrigtsen

> Should we push this one a step further, as below?

Duh!  Wrong patch, sorry,


        Stefan


diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index dd90bcf4d82..76f49e36f62 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -210,9 +210,7 @@ 'byte-run--set-compiler-macro
 (defalias 'byte-run--set-doc-string
   #'(lambda (f _args pos)
       (list 'function-put (list 'quote f)
-            ''doc-string-elt (if (numberp pos)
-                                 pos
-                               (list 'quote pos)))))
+            ''doc-string-elt pos)))
 
 (defalias 'byte-run--set-indent
   #'(lambda (f _args val)
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 200af057cd7..b1579a61fe5 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -545,7 +545,7 @@ cl-defmethod
 \(and can be extended) by the various methods of `cl-generic-generalizers'.
 
 \(fn NAME [EXTRA] [QUALIFIER] ARGS &rest [DOCSTRING] BODY)"
-  (declare (doc-string cl--defmethod-doc-pos) (indent defun)
+  (declare (doc-string #'cl--defmethod-doc-pos) (indent defun)
            (debug
             (&define                    ; this means we are defining something
              [&name [sexp   ;Allow (setf ...) additionally to symbols.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-17 18:01     ` Stefan Monnier
@ 2022-06-17 18:08       ` Lars Ingebrigtsen
  2022-06-17 18:20         ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-17 18:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> -            ''doc-string-elt (if (numberp pos)
> -                                 pos
> -                               (list 'quote pos)))))
> +            ''doc-string-elt pos)))

[...]

> -  (declare (doc-string cl--defmethod-doc-pos) (indent defun)
> +  (declare (doc-string #'cl--defmethod-doc-pos) (indent defun)

Even though there's only one of these in-tree (at least I only got one
error when I originally had the code they way you have here), I was
thinking it might break out-of-tree code...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-17 18:08       ` Lars Ingebrigtsen
@ 2022-06-17 18:20         ` Stefan Monnier
  2022-06-18 11:32           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2022-06-17 18:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> Even though there's only one of these in-tree (at least I only got one
> error when I originally had the code they way you have here), I was
> thinking it might break out-of-tree code...

That's a risk, indeed, but I couldn't find any such occurrences so far
out there in the wild, hence my question.


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-17 18:20         ` Stefan Monnier
@ 2022-06-18 11:32           ` Lars Ingebrigtsen
  2022-06-18 13:34             ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-18 11:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Even though there's only one of these in-tree (at least I only got one
>> error when I originally had the code they way you have here), I was
>> thinking it might break out-of-tree code...
>
> That's a risk, indeed, but I couldn't find any such occurrences so far
> out there in the wild, hence my question.

The gains are pretty minuscule -- we'd avoid an `if' when processing
these declarations -- so I think I'd just leave it as is out of an
overabundance of caution.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-18 11:32           ` Lars Ingebrigtsen
@ 2022-06-18 13:34             ` Stefan Monnier
  2022-06-19 11:10               ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2022-06-18 13:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> The gains are pretty minuscule -- we'd avoid an `if' when processing
> these declarations -- so I think I'd just leave it as is out of an
> overabundance of caution.

FWIW, the goal wasn't to avoid an `if` but to allow an
arbitrary expression.  But I agree the gain is minuscule.


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-18 13:34             ` Stefan Monnier
@ 2022-06-19 11:10               ` Lars Ingebrigtsen
  2022-06-19 12:57                 ` Basil L. Contovounesios
  2022-06-19 22:24                 ` Stefan Monnier
  0 siblings, 2 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-19 11:10 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> FWIW, the goal wasn't to avoid an `if` but to allow an
> arbitrary expression.  But I agree the gain is minuscule.

Perhaps we should have a quote-if-not-self-quoting function for these
things?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 11:10               ` Lars Ingebrigtsen
@ 2022-06-19 12:57                 ` Basil L. Contovounesios
  2022-06-19 13:15                   ` Lars Ingebrigtsen
  2022-06-19 22:24                 ` Stefan Monnier
  1 sibling, 1 reply; 14+ messages in thread
From: Basil L. Contovounesios @ 2022-06-19 12:57 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Monnier, emacs-devel

Lars Ingebrigtsen [2022-06-19 13:10 +0200] wrote:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> FWIW, the goal wasn't to avoid an `if` but to allow an
>> arbitrary expression.  But I agree the gain is minuscule.
>
> Perhaps we should have a quote-if-not-self-quoting function for these
> things?

macroexp-const-p, macroexp-quote, ...?

-- 
Basil



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 12:57                 ` Basil L. Contovounesios
@ 2022-06-19 13:15                   ` Lars Ingebrigtsen
  2022-06-19 16:19                     ` Michael Heerdegen
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-19 13:15 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Stefan Monnier, emacs-devel

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

>> Perhaps we should have a quote-if-not-self-quoting function for these
>> things?
>
> macroexp-const-p, macroexp-quote, ...?

I wasn't quite sure whether that would do the right thing here.

(macroexp-quote #'foo)
=> 'foo

#'foo
=> foo

for instance.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 13:15                   ` Lars Ingebrigtsen
@ 2022-06-19 16:19                     ` Michael Heerdegen
  2022-06-19 22:30                       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2022-06-19 16:19 UTC (permalink / raw)
  To: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> (macroexp-quote #'foo)
> => 'foo
>
> #'foo
> => foo
>
> for instance.

I don't follow what's wrong or unexpected here.

Michael.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 11:10               ` Lars Ingebrigtsen
  2022-06-19 12:57                 ` Basil L. Contovounesios
@ 2022-06-19 22:24                 ` Stefan Monnier
  2022-06-19 22:29                   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2022-06-19 22:24 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

>> FWIW, the goal wasn't to avoid an `if` but to allow an
>> arbitrary expression.  But I agree the gain is minuscule.
> Perhaps we should have a quote-if-not-self-quoting function for these
> things?

We do, it's called `macroexp-quote`, but that does the same as your
`if`, i.e. it does not change the semantics but just optimizes away the
`quote` when it doesn't make a difference.  Also we probably wouldn't
want to use it here because `macroexp-quote` is defined much too late
in the bootstrap (or we'd have to move it first).

My proposal was to change the semantics, rather than to "avoid if".
According to it,

    (declare (doc-string (foo bar)))

would actually set `doc-string-elt` to the return value of calling (foo
bar) rather than setting it to the list `(foo bar)`.


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 22:24                 ` Stefan Monnier
@ 2022-06-19 22:29                   ` Lars Ingebrigtsen
  2022-06-19 23:12                     ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-19 22:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> My proposal was to change the semantics, rather than to "avoid if".
> According to it,
>
>     (declare (doc-string (foo bar)))
>
> would actually set `doc-string-elt` to the return value of calling (foo
> bar) rather than setting it to the list `(foo bar)`.

Oh, right...  Hm.  I don't really have an opinion about that, but it's
pretty unusual for declare forms to not be literal, I think?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 16:19                     ` Michael Heerdegen
@ 2022-06-19 22:30                       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-19 22:30 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: emacs-devel

Michael Heerdegen <michael_heerdegen@web.de> writes:

> I don't follow what's wrong or unexpected here.

There's nothing wrong, but I wasn't able to convince myself that this
doesn't make a difference in this context.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: master f515d658e5 1/2: Don't quote numbers in byte-run--set-*
  2022-06-19 22:29                   ` Lars Ingebrigtsen
@ 2022-06-19 23:12                     ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2022-06-19 23:12 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

Lars Ingebrigtsen [2022-06-20 00:29:46] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> My proposal was to change the semantics, rather than to "avoid if".
>> According to it,
>>     (declare (doc-string (foo bar)))
>> would actually set `doc-string-elt` to the return value of calling (foo
>> bar) rather than setting it to the list `(foo bar)`.
> Oh, right...  Hm.  I don't really have an opinion about that, but it's
> pretty unusual for declare forms to not be literal, I think?

Part of the motivation was indeed to change those habits.
I think the quoting used all over the place is mostly an accident that
happens to usually be harmless, rather than a feature.


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-19 23:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <165548588979.10920.4402229762078749924@vcs2.savannah.gnu.org>
     [not found] ` <20220617171130.8EDECC01685@vcs2.savannah.gnu.org>
2022-06-17 17:58   ` master f515d658e5 1/2: Don't quote numbers in byte-run--set-* Stefan Monnier
2022-06-17 18:01     ` Stefan Monnier
2022-06-17 18:08       ` Lars Ingebrigtsen
2022-06-17 18:20         ` Stefan Monnier
2022-06-18 11:32           ` Lars Ingebrigtsen
2022-06-18 13:34             ` Stefan Monnier
2022-06-19 11:10               ` Lars Ingebrigtsen
2022-06-19 12:57                 ` Basil L. Contovounesios
2022-06-19 13:15                   ` Lars Ingebrigtsen
2022-06-19 16:19                     ` Michael Heerdegen
2022-06-19 22:30                       ` Lars Ingebrigtsen
2022-06-19 22:24                 ` Stefan Monnier
2022-06-19 22:29                   ` Lars Ingebrigtsen
2022-06-19 23:12                     ` Stefan Monnier

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).