unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Alan Mackenzie <acm@muc.de>, 66991@debbugs.gnu.org
Subject: bug#66991: Confusion in interactive-form with commands with bare interactive forms.
Date: Tue, 07 Nov 2023 12:32:12 -0500	[thread overview]
Message-ID: <jwvbkc532wm.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83wmut1pb1.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 07 Nov 2023 18:49:38 +0200")

>> (interactive-form 'x-print-frames-dialog) => (interactive "") # a primitive
>> 
>> (interactive-form 'universal-argument) => (interactive nil) # a native
>>                                                       compiled command.

Both seem acceptable: the form can be either a string interpreted
internally by `call-interactively` or an expression whose value will
be the list of arguments.  It so happens that the interpretation of ""
results in an empty list of args, just like nil.  There might be
commands out there which use alternative ways to express such an empty
list, such as

    (interactive 'nil)

[ Presumably as a result of macro expansion of something like
  ...(interactive ',args)... ]

or

    (interactive (< 4 3))

[ Presumably the result of a prank or some such :-)  ]

Where/why do you need the representation to be more ... canonical?

>> The result is the same from a byte compiled command.
>>
>> Write (defun foo () (interactive)) in *scratch*, and C-M-x to evaluate
>> it:
>> (interactive-form 'foo) => (interactive).

For non-compiled functions, we just use `assq` on the body.
It's arguably not 100% correct, but it gets the job done cheaply.
It usually doesn't matter because `cadr` on this result is still nil.

>> That's three different inconsistent ways of expressing "(interactive".

Different, yes, but I don't see what's inconsistent about it, except
maybe for the fact that `interactive-form` can change from
`(interactive)` for an interpreted function to
`(interactive nil)` for the same function once it's byte-compiled, but
note that `(interactive EXP)` will generally change once byte-compiled
because EXP gets byte-compiled as well, so you generally can't presume
that `interactive-form` returns the exact same data-structure before and
after byte-compilation: the two should be "equivalent" but not
necessarily identical.


        Stefan






      parent reply	other threads:[~2023-11-07 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 16:38 bug#66991: Confusion in interactive-form with commands with bare interactive forms Alan Mackenzie
2023-11-07 16:49 ` Eli Zaretskii
2023-11-07 17:10   ` Alan Mackenzie
2023-11-07 17:38     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-08  8:56       ` Alan Mackenzie
2023-11-08 12:29         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-07 17:32   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbkc532wm.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=66991@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public 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).