unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
@ 2016-06-30 14:11 ` Robert Weiner
  2016-06-30 14:51   ` Drew Adams
                     ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Robert Weiner @ 2016-06-30 14:11 UTC (permalink / raw)
  To: emacs-devel; +Cc: 23873, Stephen Berman

Is there a Lisp function to extract the argument list of a byte-coded
function when it uses the bitstring arg descriptor in its first
element (see below for the Elisp manual doc on this)?

I would suggest that the documentation be updated to describe how to
get the argument signature in this situation, as it is silent on that.

This has come up when a standard function was advised and we need to
get its argument list for some code handling.

Thanks,

Bob

---------

   Internally, a byte-code function object is much like a vector; its
elements can be accessed using ‘aref’.  Its printed representation is
like that for a vector, with an additional ‘#’ before the opening ‘[’.
It must have at least four elements; there is no maximum number, but
only the first six elements have any normal use.  They are:

ARGDESC
     The descriptor of the arguments.  This can either be a list of
     arguments, as described in *note Argument List::, or an integer
     encoding the required number of arguments.  In the latter case, the
     value of the descriptor specifies the minimum number of arguments
     in the bits zero to 6, and the maximum number of arguments in bits
     8 to 14.  If the argument list uses ‘&rest’, then bit 7 is set;
     otherwise it’s cleared.

     If ARGDESC is a list, the arguments will be dynamically bound
     before executing the byte code.  If ARGDESC is an integer, the
     arguments will be instead pushed onto the stack of the byte-code
     interpreter, before executing the code.



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

* RE: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-06-30 14:11 ` Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list Robert Weiner
@ 2016-06-30 14:51   ` Drew Adams
  2016-06-30 15:46   ` bug#23873: " Robert Weiner
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2016-06-30 14:51 UTC (permalink / raw)
  To: rswgnu, emacs-devel; +Cc: 23873, Stephen Berman

Please don't post to both the bug list and emacs-devel.
Choose one.  Thx.



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

* Re: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-06-30 14:11 ` Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list Robert Weiner
  2016-06-30 14:51   ` Drew Adams
@ 2016-06-30 15:46   ` Robert Weiner
  2016-06-30 23:20     ` Richard Stallman
  2016-06-30 16:30   ` Robert Weiner
  2016-07-06 21:57   ` bug#23873: " Robert Weiner
  3 siblings, 1 reply; 11+ messages in thread
From: Robert Weiner @ 2016-06-30 15:46 UTC (permalink / raw)
  To: emacs-devel; +Cc: 23873

On Thu, Jun 30, 2016 at 10:11 AM, Robert Weiner <rsw@gnu.org> wrote:
> I would suggest that the documentation be updated to describe how to
> get the argument signature in this situation, as it is silent on that.

For years, XEmacs has had functions for accessing parts of
byte-compiled code.  It would be great if Emacs had some equivalents.
Below is the documentation on those functions from the XEmacs Lisp Manual:

The following primitives are provided for accessing the elements of a
compiled-function object.

Function: compiled-function-arglist function
  This function returns the argument list of compiled-function object function.

Function: compiled-function-instructions function
  This function returns a string describing the byte-code instructions
of compiled-function object function.

Function: compiled-function-constants function
  This function returns the vector of Lisp objects referenced by
compiled-function object function.

Function: compiled-function-stack-depth function
  This function returns the maximum stack size needed by
compiled-function object function.

Function: compiled-function-doc-string function
  This function returns the doc string of compiled-function object
function, if available.

Function: compiled-function-interactive function
  This function returns the interactive spec of compiled-function
object function, if any. The return value is nil or a two-element
list, the first element of which is the symbol interactive and the
second element is the interactive spec (a string or Lisp form).

Function: compiled-function-domain function
  This function returns the domain of compiled-function object
function, if any. The result will be a string or nil.



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

* Re: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-06-30 14:11 ` Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list Robert Weiner
  2016-06-30 14:51   ` Drew Adams
  2016-06-30 15:46   ` bug#23873: " Robert Weiner
@ 2016-06-30 16:30   ` Robert Weiner
  2016-07-06 21:57   ` bug#23873: " Robert Weiner
  3 siblings, 0 replies; 11+ messages in thread
From: Robert Weiner @ 2016-06-30 16:30 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stephen Berman

On Thu, Jun 30, 2016 at 10:11 AM, Robert Weiner <rsw@gnu.org> wrote:
> Is there a Lisp function to extract the argument list of a byte-coded
> function when it uses the bitstring arg descriptor in its first
> element (see below for the Elisp manual doc on this)?

I see now through disassembly of such byte-coded functions that the
byte-compiler discards the actual names of the arguments and the
disassembler just outputs placeholders for them.  Why not preserve the
argument signature as is done for functions with a fixed number of
arguments?  In Lisp, we should be able to reason about compiled code
too, right?

Bob



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

* Re: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-06-30 15:46   ` bug#23873: " Robert Weiner
@ 2016-06-30 23:20     ` Richard Stallman
  2016-07-01 12:14       ` Robert Weiner
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2016-06-30 23:20 UTC (permalink / raw)
  To: rswgnu; +Cc: 23873, emacs-devel

[[[ 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. ]]]

  > For years, XEmacs has had functions for accessing parts of
  > byte-compiled code.  It would be great if Emacs had some equivalents.

There is nothing wrong with this, but it would be clutter.
Why do you want them?

Perhaps they can be defsubrs defined in a file that you'd load
at compile time.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




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

* Re: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-06-30 23:20     ` Richard Stallman
@ 2016-07-01 12:14       ` Robert Weiner
  2016-07-01 14:01         ` Drew Adams
  2016-07-01 22:04         ` Richard Stallman
  0 siblings, 2 replies; 11+ messages in thread
From: Robert Weiner @ 2016-07-01 12:14 UTC (permalink / raw)
  To: Richard Stallman; +Cc: 23873, emacs-devel

On Thu, Jun 30, 2016 at 7:20 PM, Richard Stallman <rms@gnu.org> wrote:
>   > For years, XEmacs has had functions for accessing parts of
>   > byte-compiled code.  It would be great if Emacs had some equivalents.
>
> There is nothing wrong with this, but it would be clutter.
> Why do you want them?

In a few places, Hyperbole uses its own function to overload existing
functions with its own and needs access to the function's argument
signature to do this.  For reasons of backward compatibility,
Hyperbole has not used defadvice.  In another case, we want to know if
a function's signature has changed for a conditional dispatch.

> Perhaps they can be defsubrs defined in a file that you'd load
> at compile time.

That would be fine with me.  I would be willing to be a tester and as
a first step need only the argument signature extraction routine.
Is anyone interested in implementing this?

Bob



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

* RE: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-07-01 12:14       ` Robert Weiner
@ 2016-07-01 14:01         ` Drew Adams
  2016-07-01 22:04         ` Richard Stallman
  1 sibling, 0 replies; 11+ messages in thread
From: Drew Adams @ 2016-07-01 14:01 UTC (permalink / raw)
  To: rswgnu, Richard Stallman; +Cc: 23873, emacs-devel

> In a few places, Hyperbole uses its own function to overload existing
> functions with its own and needs access to the function's argument
> signature to do this.  For reasons of backward compatibility,
> Hyperbole has not used defadvice.  In another case, we want to know if
> a function's signature has changed for a conditional dispatch.

Not a general solution, but this approach often works if the
signature changed:

(condition-case nil          ; Emacs 22+ accepts a default.
    (read-face-name "Face: " default-face)
  (wrong-number-of-arguments (read-face-name "Face: ")))

Or this:

(condition-case nil
    (funcall cmd arg)         ; Try to use string candidate `arg'.
  ;; If that didn't work, use a symbol or number candidate.
  (wrong-type-argument (funcall cmd (car (read-from-string arg))))
  (wrong-number-of-arguments (funcall #'icicle-help-on-candidate))) ; Punt



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

* Re: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-07-01 12:14       ` Robert Weiner
  2016-07-01 14:01         ` Drew Adams
@ 2016-07-01 22:04         ` Richard Stallman
  2016-07-01 22:43           ` Robert Weiner
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2016-07-01 22:04 UTC (permalink / raw)
  To: rswgnu; +Cc: 23873, emacs-devel

[[[ 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. ]]]

  > In a few places, Hyperbole uses its own function to overload existing
  > functions with its own and needs access to the function's argument
  > signature to do this.

Rather than provide a slightly cleaner way of doing this, I'd rather
we replace it with something much cleaner.

When Hyperbole is incorporated into Emacs, it should not override any
function definitions located elsewhere in Emacs.  Not one!

Instead, we should fix those function definitions to do what Hyperbole
needs.  Either we could include in their normal definitions the
functionality that Hyperbole uses, or we could give them hooks so that
Hyperbole can add functionality to them in a modular way.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




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

* Re: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-07-01 22:04         ` Richard Stallman
@ 2016-07-01 22:43           ` Robert Weiner
  0 siblings, 0 replies; 11+ messages in thread
From: Robert Weiner @ 2016-07-01 22:43 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

On Fri, Jul 1, 2016 at 6:04 PM, Richard Stallman <rms@gnu.org> wrote:
> When Hyperbole is incorporated into Emacs, it should not override any
> function definitions located elsewhere in Emacs.  Not one!
>
> Instead, we should fix those function definitions to do what Hyperbole
> needs.  Either we could include in their normal definitions the
> functionality that Hyperbole uses, or we could give them hooks so that
> Hyperbole can add functionality to them in a modular way.

I totally agree for the version integrated and look forward to it.  If
there remains an external package for backwards compatibility, it may
still need conditionalized overrides.

Bob



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

* Re: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-06-30 14:11 ` Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list Robert Weiner
                     ` (2 preceding siblings ...)
  2016-06-30 16:30   ` Robert Weiner
@ 2016-07-06 21:57   ` Robert Weiner
  2016-07-06 23:32     ` Drew Adams
  3 siblings, 1 reply; 11+ messages in thread
From: Robert Weiner @ 2016-07-06 21:57 UTC (permalink / raw)
  To: emacs-devel; +Cc: 23873, Stephen Berman

Are either of these likely to happen?  Is there anyone who presently
works on the byte compiler?

  1. The source argument signature for functions that use an arg
descriptor will be stored in the byte-compiled code.

  2. There will be a function to access this signature.

Thanks,

Bob



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

* RE: bug#23873: Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list
  2016-07-06 21:57   ` bug#23873: " Robert Weiner
@ 2016-07-06 23:32     ` Drew Adams
  0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2016-07-06 23:32 UTC (permalink / raw)
  To: rswgnu, emacs-devel; +Cc: 23873, Stephen Berman

> Are either of these likely to happen?  Is there anyone who presently
> works on the byte compiler?
> 
>   1. The source argument signature for functions that use an arg
> descriptor will be stored in the byte-compiled code.
> 
>   2. There will be a function to access this signature.

(There is in Common Lisp, BTW.)



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

end of thread, other threads:[~2016-07-06 23:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <871t3edfd9.fsf@gmx.net>
2016-06-30 14:11 ` Emacs 24.0.94: With function argdesc bitstring, Elisp manual does not say how to get arg list Robert Weiner
2016-06-30 14:51   ` Drew Adams
2016-06-30 15:46   ` bug#23873: " Robert Weiner
2016-06-30 23:20     ` Richard Stallman
2016-07-01 12:14       ` Robert Weiner
2016-07-01 14:01         ` Drew Adams
2016-07-01 22:04         ` Richard Stallman
2016-07-01 22:43           ` Robert Weiner
2016-06-30 16:30   ` Robert Weiner
2016-07-06 21:57   ` bug#23873: " Robert Weiner
2016-07-06 23:32     ` Drew Adams

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).