From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: ELisp function prototypes and local function name
Date: Fri, 08 Apr 2011 00:43:44 -0500 [thread overview]
Message-ID: <87fwpt70xb.fsf@lifelogs.com> (raw)
In-Reply-To: 87mxk1crxg.fsf@uwakimon.sk.tsukuba.ac.jp
On Fri, 08 Apr 2011 13:01:31 +0900 "Stephen J. Turnbull" <stephen@xemacs.org> wrote:
SJT> Ted Zlatanov writes:
>> It looks like the XEmacs `function-arglist' is not useful, in any case.
>> It depends too much on the underlying implementation.
SJT> Sure, but in XEmacs there's only one such (with three parts: one for
SJT> subrs, one for lambda lists, and one for byte-code objects). Random
SJT> third-party stuff won't work, but it doesn't have to; random third
SJT> parties can and should use the defined API. That's hardly a
SJT> controversial concept.
SJT> Evidently this won't work in Emacs out of the box, but surely it's
SJT> worth moving in that direction, and having third parties with "better
SJT> ideas" for basic introspection contribute them to core rather than
SJT> implement them in complex and fragile packages like eieio?
I'm OK with `function-arglist' in Emacs but I'm not the one to implement
it. I don't know enough about the concepts. I looked through the C
source to learn more and here's what I found:
1) my examples with `mapc' and `mapcar' were not good, since those are
built-in functions. `help-function-arglist' is in fact the best Emacs
in-core solution and will provide the arguments when possible. I think
the same situation is valid in XEmacs. I simply didn't understand what
it does when I tested it on `mapc' and assumed it generally couldn't
provide the arguments.
2) Lambdas, closures, macros, and byte-compiled functions have the
arguments to build the function arglist with the argument names. You
just need to look with `aref' or `nth' in the right place.
3) built-in functions like `mapc' don't provide their argument names,
just the number of arguments with `subr-arity'. So their
`symbol-function' will return a #subr object and the symbol doesn't have
a function definition in its "function" slot (nor can it, since it's C
code).
So `*function-arglist' in Emacs and XEmacs do the best they can, but it
would be nice if DEFUN could do more to provide the names of the
arguments. It would involve either changing DEFUN, though, or trusting
the docstring as `eldoc-function-argstring' does.
I think it would make sense to put at least some of this in the ELisp
manual. If it's already in there, I didn't see it. It was really
educational to discover it for myself :)
Ted
prev parent reply other threads:[~2011-04-08 5:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 13:36 ELisp function prototypes and local function name Ted Zlatanov
2011-04-06 15:19 ` Robert Pluim
2011-04-06 15:58 ` Ted Zlatanov
2011-04-07 0:25 ` Stephen J. Turnbull
2011-04-07 2:27 ` Ted Zlatanov
2011-04-07 3:27 ` Stephen J. Turnbull
2011-04-07 3:55 ` Jambunathan K
2011-04-07 5:43 ` Stephen J. Turnbull
2011-04-07 20:51 ` Ted Zlatanov
2011-04-08 4:01 ` Stephen J. Turnbull
2011-04-08 5:43 ` Ted Zlatanov [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=87fwpt70xb.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=emacs-devel@gnu.org \
/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).