[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ELisp function prototypes and local function name

From: Ted Zlatanov
Subject: Re: ELisp function prototypes and local function name
Date: Fri, 08 Apr 2011 00:43:44 -0500
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux)

On Fri, 08 Apr 2011 13:01:31 +0900 "Stephen J. Turnbull" <address@hidden> 

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

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]