Subject: bug#66991: Confusion in interactive-form with commands with bare interactive forms.

From: Stefan Monnier <[email-masked]>
Date: Tue, 07 Nov 2023 12:32:12 -0500

>> (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