From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Arbitrary function: find the number(s) of expected arguments Date: Sat, 19 Mar 2016 16:14:04 +0000 Message-ID: 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: multipart/alternative; boundary=001a11407f1e982bfc052e6927b7 X-Trace: ger.gmane.org 1458404071 10554 80.91.229.3 (19 Mar 2016 16:14:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2016 16:14:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii , Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 19 17:14:24 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 1ahJW9-0006O4-Gn for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2016 17:14:21 +0100 Original-Received: from localhost ([::1]:49543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahJW8-00053F-Ni for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2016 12:14:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahJW4-00051x-AU for emacs-devel@gnu.org; Sat, 19 Mar 2016 12:14:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahJW3-0004NE-B9 for emacs-devel@gnu.org; Sat, 19 Mar 2016 12:14:16 -0400 Original-Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:34127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahJW3-0004NA-31; Sat, 19 Mar 2016 12:14:15 -0400 Original-Received: by mail-lf0-x233.google.com with SMTP id e196so8319819lfg.1; Sat, 19 Mar 2016 09:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hAM9mGZ3efpLQJkUKTBhT7wqLYMs1vBC/EDKXcZhTV8=; b=lckfKfCBTxDi/WHhCUU93p6O7F1FNyLehhpoDfpUyHQhc/BFZdQf1pYtmpoRONW8E2 2HQVP+8GhZ3eERWpkmuxT0q8635TOfDUJSDqhJzsNZ8Qu+msf7r/mtPCqIhonhy+8QcE +0Gtt5kc+q7+AvGKXKpo1svvU5MDDUVk2TWxe5+xtXZGdKR/4jbNSVxIOzhzmH9qc4lb HmOpWJ5gZilNyAP8WYkxvYx7hus131cgs6vXcV4cEYeIBkSBHLJ4J3xyaH+7vw37QdyI HKq0QcUHv6QhMnfcapBo4SH9gZVGBbOe6n73TzHKHe9gwfQPxutf7GpHBr5ok9YG9JPr DqTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hAM9mGZ3efpLQJkUKTBhT7wqLYMs1vBC/EDKXcZhTV8=; b=eGMD5PVdyPqVYoixN55s9fPAi9cjVxgIz8johb9FREBtAUz7BP8rhCOpvzG1+gPlH1 eiNopuCQ6Waxq+5qt6SOFMgsmuOOUA7beaqmQglUp+sko74VFOKo37sudPXTwIN+00S5 PrdpSDeStjzs9WjA/bUzzFlZTCHkxQcpGYPI4iX0D78GQWCFmLiwhWIAVjUMQmNAmtgJ +U5ALELMnSGdtuVEIef6Vpv41JJYcc29PgN4w+iDpD0VFDqCmcY7GTp8EIn3EJGouN1Y 53SOqcJNzcJAdl+iukEGr6EgugVGYXb2fUGBgiwJIwoVJVCKZdLNV2EsZGnSOFWGRBzV NISQ== X-Gm-Message-State: AD7BkJJvw5EpKvigzmL8EilAZNsByTLq6gsIYSXpDpx+Dfls9iYDKrKSDho6dpqYTTQRgb8h9HHrBBI4kG5M2w== X-Received: by 10.25.18.211 with SMTP id 80mr8120550lfs.127.1458404054279; Sat, 19 Mar 2016 09:14:14 -0700 (PDT) In-Reply-To: <838u1e8od1.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::233 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:201871 Archived-At: --001a11407f1e982bfc052e6927b7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii schrieb am Sa., 19. M=C3=A4rz 2016 um 16:44 Uh= r: > > For example: > > > > > > (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. > Knowing the arity in cases like this requires either evaluating the function, or complex parsing of its definition. It is very reasonable to assume that (func-arity 'g) would return (0 . many), because that is g's arity as far as the Lisp interpreter is concerned. --001a11407f1e982bfc052e6927b7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Sa., 19. M=C3=A4rz 2016 um 16:44=C2=A0Uhr:
> For example:
>
> > > (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 argum= ents",
> whereby it doesn't.=C2=A0 The condition-case solution with the wro= ng 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.=C2=A0 So I don't see any insoluble problems here.

Knowing the arity in cases like this requi= res either evaluating the function, or complex parsing of its definition. I= t is very reasonable to assume that (func-arity 'g) would return (0 . m= any), because that is g's arity as far as the Lisp interpreter is conce= rned.=C2=A0
--001a11407f1e982bfc052e6927b7--