From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: Arbitrary function: find the number(s) of expected arguments Date: Sat, 19 Mar 2016 16:57:59 +0100 Message-ID: <87pouqe9yw.fsf@web.de> References: <56E8906C.5050405@lanl.gov> <83egb68vfy.fsf@gnu.org> <87zituefp9.fsf@web.de> <83a8lu8srs.fsf@gnu.org> <87twk2ebp2.fsf@web.de> <838u1e8od1.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1458403120 29175 80.91.229.3 (19 Mar 2016 15:58:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2016 15:58:40 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 19 16:58:28 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ahJGk-0005Wk-JE for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2016 16:58:26 +0100 Original-Received: from localhost ([::1]:49335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahJGg-0005PJ-T3 for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2016 11:58:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahJGc-0005M7-Sw for emacs-devel@gnu.org; Sat, 19 Mar 2016 11:58:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahJGZ-0000Se-Nr for emacs-devel@gnu.org; Sat, 19 Mar 2016 11:58:18 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:46734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahJGZ-0000S3-Ho for emacs-devel@gnu.org; Sat, 19 Mar 2016 11:58:15 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ahJGU-0005PC-6b for emacs-devel@gnu.org; Sat, 19 Mar 2016 16:58:10 +0100 Original-Received: from dslb-094-218-210-027.094.218.pools.vodafone-ip.de ([94.218.210.27]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Mar 2016 16:58:10 +0100 Original-Received: from michael_heerdegen by dslb-094-218-210-027.094.218.pools.vodafone-ip.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Mar 2016 16:58:10 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-094-218-210-027.094.218.pools.vodafone-ip.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) Cancel-Lock: sha1:5JngqDG/AllAlVSB+MtGnwc8bpc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:201869 Archived-At: Eli Zaretskii writes: > > > > (defun f (a b) (list a b)) > > > > > > > > (defalias 'g (apply-partially #'f 1)) > > > > > > > > what would (func-arity 'g) return? > > > > > > Ideally, it should return (1 . 1). > > > > This signature can be interpreted as "accepts any number of arguments", > > whereby it doesn't. The condition-case solution with the wrong number > > of args handler at least also catches this case. > > But Emacs itself clearly _knows_ that only one argument is acceptable. > So a function that replicates the steps made by the Lisp interpreter > to arrive at this conclusion will be able to reach the same > conclusion. So I don't see any insoluble problems here. My examples where just special examples. Generally, there is no clear border or distinction between some kind of "wrapper" around a function (like apply-partially or advice-add create), or a function that calls another function in it's body. So what should `function-arity' return? The actual arity of the function? An arity that takes information about some known kinds of wrappers into account? No matter how you do it: the result will never give you a clear answer. Even if the user understands what he is doing: if `function-arity' can't answer the question whether a certain number of arguments is allowed, it is of not much value. Michael.