From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: ELisp function prototypes and local function name Date: Thu, 07 Apr 2011 15:51:18 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <8739ltrdix.fsf@lifelogs.com> References: <87ei5fqz6h.fsf@lifelogs.com> <87k4f7pe2f.fsf@lifelogs.com> <874o6arjpz.fsf@uwakimon.sk.tsukuba.ac.jp> <87mxk27q3d.fsf@lifelogs.com> <871v1erb9j.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1302209507 24811 80.91.229.12 (7 Apr 2011 20:51:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Apr 2011 20:51:47 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 07 22:51:43 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7wB4-0000hh-Tp for ged-emacs-devel@m.gmane.org; Thu, 07 Apr 2011 22:51:43 +0200 Original-Received: from localhost ([127.0.0.1]:59418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7wB4-0000l1-BF for ged-emacs-devel@m.gmane.org; Thu, 07 Apr 2011 16:51:42 -0400 Original-Received: from [140.186.70.92] (port=40168 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7wAz-0000kw-CM for emacs-devel@gnu.org; Thu, 07 Apr 2011 16:51:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7wAx-0007kT-7r for emacs-devel@gnu.org; Thu, 07 Apr 2011 16:51:37 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:33227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7wAw-0007k0-Ts for emacs-devel@gnu.org; Thu, 07 Apr 2011 16:51:35 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q7wAv-0000a4-Bf for emacs-devel@gnu.org; Thu, 07 Apr 2011 22:51:33 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Apr 2011 22:51:33 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Apr 2011 22:51:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 85 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:6xwLcduANLw75XCnxG9Sa5P2cKw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138294 Archived-At: On Thu, 07 Apr 2011 12:27:52 +0900 "Stephen J. Turnbull" wrote: SJT> Ted Zlatanov writes: >> But it doesn't correspond to the advertised prototype >> "(mapc FUNCTION SEQUENCE)" and loses the argument names. SJT> Oh well. SJT> (function-arglist 'mapc) => (mapc FUNCTION SEQUENCE &rest SEQUENCES) SJT> where I live. I think Aidan Kehoe knows most about that code SJT> currently, but I don't know what the assignment status is. Interesting. So, disregarding the string-oriented help.el functions, in Emacs we have `semanticdb-elisp-sym-function-arglist' which extracts the actual function from the symbol: #+begin_src lisp (defun semanticdb-elisp-sym-function-arglist (sym) "Get the argument list for SYM. Deal with all different forms of function. This was snarfed out of eldoc." (let* ((prelim-def (let ((sd (and (fboundp sym) (symbol-function sym)))) (and (symbolp sd) (condition-case err (setq sd (indirect-function sym)) (error (setq sd nil)))) sd)) (def (if (eq (car-safe prelim-def) 'macro) (cdr prelim-def) prelim-def)) (arglist (cond ((null def) nil) ((byte-code-function-p def) ;; This is an eieio compatibility function. ;; We depend on EIEIO, so use this. (eieio-compiled-function-arglist def)) ((eq (car-safe def) 'lambda) (nth 1 def)) (t nil)))) arglist)) #+end_src but that returns nil for everything when I tried it. Also it calls `eieio-compiled-function-arglist' which is: #+begin_src lisp (eval-and-compile ;; About the above. EIEIO must process its own code when it compiles ;; itself, thus, by eval-and-compiling outselves, we solve the problem. ;; Compatibility (if (fboundp 'compiled-function-arglist) ;; XEmacs can only access a compiled functions arglist like this: (defalias 'eieio-compiled-function-arglist 'compiled-function-arglist) ;; Emacs doesn't have this function, but since FUNC is a vector, we can just ;; grab the appropriate element. (defun eieio-compiled-function-arglist (func) "Return the argument list for the compiled function FUNC." (aref func 0)) ) #+end_src So `eieio-compiled-function-arglist' is what I need, but `aref' doesn't work on any functions I've tried: (aref (indirect-function 'mapcar) 0) => (wrong-type-argument arrayp #) (aref (symbol-function 'mapcar) 0) => (wrong-type-argument arrayp #) ;; aref still doesn't work, but nth does on lambdas (nth 1 (lambda (a b))) => (a b) It looks like the XEmacs `function-arglist' is not useful, in any case. It depends too much on the underlying implementation. Ted