From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.devel Subject: Re: Arbitrary function: find the number(s) of expected arguments Date: Sat, 19 Mar 2016 17:51:39 +0100 Message-ID: References: <56E8906C.5050405@lanl.gov> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a113e1bd470650c052e69ad5c X-Trace: ger.gmane.org 1458406331 11279 80.91.229.3 (19 Mar 2016 16:52:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2016 16:52:11 +0000 (UTC) Cc: emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 19 17:52:04 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 1ahK6Y-000372-PE for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2016 17:51:59 +0100 Original-Received: from localhost ([::1]:49685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahK6Y-0000Pe-0o for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2016 12:51:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahK6I-0000PY-81 for emacs-devel@gnu.org; Sat, 19 Mar 2016 12:51:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahK6G-0007OX-O1 for emacs-devel@gnu.org; Sat, 19 Mar 2016 12:51:42 -0400 Original-Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:33030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahK6G-0007OS-GW for emacs-devel@gnu.org; Sat, 19 Mar 2016 12:51:40 -0400 Original-Received: by mail-oi0-x233.google.com with SMTP id d205so111425494oia.0 for ; Sat, 19 Mar 2016 09:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=En71nHKH+1P/jUQSvFBrYZoj8raY1MIwH0Bdw7LPEu8=; b=qCeRBskJdnESCJhrfHyIYDaWlHG9GJ9wnHTC0kxidfXStmHVWEPNNi3j2SaQ+2v1Fy tf9WBsqvfk2qaX1nBizNcHv1EvKJhgm5YtYMjdo29dGHzdP/qg+O9kZAPa6Tk+3gTOce fzv5q5hi4E/JuD1kUKJ9y/pffkSXuNE7pwrzVhPR4mPAFDSAbKJS09Vvlhe0Nk72N1sy ag0BOLQ4YPtOEYBUzXih11Yh077th02OeBAvwOGmCOQ2dRZD++xLB6+/RVIy9mIkBEBH j5GEfrWubvKDoQheaTFMdwoKOKOnnmyXg83sKQcXcp7smTgO5yBDi+l9cnyy45xUyI9z 4ZUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=En71nHKH+1P/jUQSvFBrYZoj8raY1MIwH0Bdw7LPEu8=; b=Ms2us3Tz49z5bCi+kDm83z312N91sUkGtmwZ6ahEAp4YGV71nhKd2pLG5tzPtCvbcY qPdyl/aVJTRwCmH4KpebddMGxPi9holqDfU7mHB5/CZI7GdsYuIex8SK3QwkqXae5dRl REIAc6Ad7f9enEbDxZ1+EgLa1F98dhYkhoIsMQ2dzei2+nX/MkfUNJH7Cu4Rcxc9j2nE wVaDRDH4vaul7io+z2QeOsNpxQkyNWx3v5H2us6/IXvQ7rGv5QkEKHmYGtIDHl0Ibn2T s0hkOYTfQVAlokcmjKhJQo9hyfQhjf4hbQCQj4XtjdL/PQcHS3SQbcLv3Huww1i1VX8Q c6jQ== X-Gm-Message-State: AD7BkJKe514a65JSXkA99078zC5CxDTqqkzc3y5+SanQFLVa5/wWUImttVmIjI73Jb26ijjxVBmYJneuHH/P4w== X-Received: by 10.157.20.161 with SMTP id d30mr486281ote.165.1458406299785; Sat, 19 Mar 2016 09:51:39 -0700 (PDT) Original-Received: by 10.202.71.7 with HTTP; Sat, 19 Mar 2016 09:51:39 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::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:201882 Archived-At: --001a113e1bd470650c052e69ad5c Content-Type: multipart/alternative; boundary=001a113e1bd4706507052e69ad5a --001a113e1bd4706507052e69ad5a Content-Type: text/plain; charset=UTF-8 Approximate patch, without documentation. If this is accepted, I can write documentation too. I submitted legal papers for FSF years ago. (func-arity 'car) (1 . 1) (func-arity 'caar) (1 . 1) (func-arity 'magit-log-all) (0 . 2) (func-arity 'format) (1 . many) (func-arity (lambda (&rest x))) (0 . many) Return value is the same as with `subr-arity' except here any callable is accepted and you don't need `symbol-function' or `indirect-function'. Autoloading is also supported transparently. Paul --001a113e1bd4706507052e69ad5a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Approximate patch, without docu= mentation.=C2=A0 If this is accepted, I can write documentation too.=C2=A0 = I submitted legal papers for FSF years ago.

=C2=A0 =C2= =A0 (func-arity 'car) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(1 . 1)
=C2=A0 = =C2=A0 (func-arity 'caar) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (1 . 1)
=C2=A0 =C2= =A0 (func-arity 'magit-log-all) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(0 . 2)
=C2=A0 =C2=A0 (func-arity 'f= ormat) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (1 . = many)
=C2=A0 =C2=A0 (func-arity (lambda (&a= mp;rest x))) =C2=A0 =C2=A0 =C2=A0 =C2=A0(0 . many)

Return value is the same as wi= th `subr-arity' except here any callable is accepted and you don't = need `symbol-function' or `indirect-function'.=C2=A0 Autoloading is= also supported transparently.

Paul
--001a113e1bd4706507052e69ad5a-- --001a113e1bd470650c052e69ad5c Content-Type: text/plain; charset=US-ASCII; name="func-arity.diff" Content-Disposition: attachment; filename="func-arity.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ilzdg4m10 ZGlmZiAtLWdpdCBhL3NyYy9ieXRlY29kZS5jIGIvc3JjL2J5dGVjb2RlLmMKaW5kZXggOWFlMmU4 Mi4uY2EwNGMyOCAxMDA2NDQKLS0tIGEvc3JjL2J5dGVjb2RlLmMKKysrIGIvc3JjL2J5dGVjb2Rl LmMKQEAgLTE5ODcsNiArMTk4NywyMiBAQCBleGVjX2J5dGVfY29kZSAoTGlzcF9PYmplY3QgYnl0 ZXN0ciwgTGlzcF9PYmplY3QgdmVjdG9yLCBMaXNwX09iamVjdCBtYXhkZXB0aCwKICAgcmV0dXJu IHJlc3VsdDsKIH0KIAorTGlzcF9PYmplY3QKK2dldF9ieXRlX2NvZGVfYXJpdHkgKExpc3BfT2Jq ZWN0IGFyZ3NfdGVtcGxhdGUpCit7CisgIGlmIChJTlRFR0VSUCAoYXJnc190ZW1wbGF0ZSkpCisg ICAgeworICAgICAgcHRyZGlmZl90IGF0ID0gWElOVCAoYXJnc190ZW1wbGF0ZSk7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iAoU1VCUlAgKGZ1bmN0aW9uKSkKKyAgICB7CisgICAgICBtaW5h cmdzID0gWFNVQlIgKGZ1bmN0aW9uKS0+bWluX2FyZ3M7CisgICAgICBtYXhhcmdzID0gWFNVQlIg KGZ1bmN0aW9uKS0+bWF4X2FyZ3M7CisgICAgICByZXN1bHQgID0gRmNvbnMgKG1ha2VfbnVtYmVy IChtaW5hcmdzKSwKKyAgICAgICAgICAgICAgICAgICAgICAgbWF4YXJncyA9PSBNQU5ZID8gICAg ICAgIFFtYW55CisgICAgICAgICAgICAgICAgICAgICAgIDogbWF4YXJncyA9PSBVTkVWQUxMRUQg PyBRdW5ldmFsbGVkCisgICAgICAgICAgICAgICAgICAgICAgIDogICAgICAgICAgICAgICAgICAg ICAgICBtYWtlX251bWJlciAobWF4YXJncykpOworICAgIH0KKyAgZWxzZSBpZiAoQ09NUElMRURQ IChmdW5jdGlvbikpCisgICAgcmVzdWx0ID0gbGFtYmRhX2FyaXR5IChmdW5jdGlvbik7CisgIGVs c2UKKyAgICB7CisgICAgICBpZiAoTklMUCAoZnVuY3Rpb24pKQorCXhzaWduYWwxIChRdm9pZF9m dW5jdGlvbiwgb3JpZ2luYWwpOworICAgICAgaWYgKCFDT05TUCAoZnVuY3Rpb24pKQorCXhzaWdu YWwxIChRaW52YWxpZF9mdW5jdGlvbiwgb3JpZ2luYWwpOworICAgICAgZnVuY2FyID0gWENBUiAo ZnVuY3Rpb24pOworICAgICAgaWYgKCFTWU1CT0xQIChmdW5jYXIpKQorCXhzaWduYWwxIChRaW52 YWxpZF9mdW5jdGlvbiwgb3JpZ2luYWwpOworICAgICAgaWYgKEVRIChmdW5jYXIsIFFsYW1iZGEp CisJICB8fCBFUSAoZnVuY2FyLCBRY2xvc3VyZSkpCisJcmVzdWx0ID0gbGFtYmRhX2FyaXR5IChm dW5jdGlvbik7CisgICAgICBlbHNlIGlmIChFUSAoZnVuY2FyLCBRYXV0b2xvYWQpKQorCXsKKwkg IEZhdXRvbG9hZF9kb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KyAgICAgIHN5bXNf bGVmdCA9IEFSRUYgKGZ1biwgQ09NUElMRURfQVJHTElTVCk7CisgICAgICBpZiAoSU5URUdFUlAg KHN5bXNfbGVmdCkpCisgICAgICAgIHJldHVybiBnZXRfYnl0ZV9jb2RlX2FyaXR5IChzeW1zX2xl ZnQpOworICAgIH0KKyAgZWxzZQorICAgIGVtYWNzX2Fib3J0ICgpOworCisgIG1pbmFyZ3MgPSBt YXhhcmdzID0gb3B0aW9uYWwgPSAwOworICBmb3IgKDsgQ09OU1AgKHN5bXNfbGVmdCk7IHN5bXNf bGVmdCA9IFhDRFIgKHN5bXNfbGVmdCkpCisgICAgeworICAgICAgbmV4dCA9IFhDQVIgKHN5bXNf bGVmdCk7CisgICAgICBpZiAoIVNZTUJPTFAgKG5leHQpKQorCXhzaWduYWwxIChRaW52YWxpZF9m dW5jdGlvbiwgZnVuKTsKKworICAgICAgaWYgKEVRIChuZXh0LCBRYW5kX3Jlc3QpKQorCXJldHVy biBGY29ucyAobWFrZV9udW1iZXIgKG1pbmFyZ3MpLCBRbWFueSk7CisgICAgICBlbHNlIGlmIChF USAobmV4dCwgUWFuZF9vcHRpb25hbCkpCisJb3B0aW9uYWwgPSAxOworICAgICAgZWxzZQorCXsK KyAgICAgICAgICBpZiAoIW9wdGlvbmFsKQorICAgICAgICAgICAgbWluYXJncysrOworICAgICAg ICAgIG1heGFyZ3MrKzsKKyAgICAgICAgfQorICAgIH0KKworICBpZiAoIU5JTFAgKHN5bXNfbGVm dCkpCisgICAgeHNpZ25hbDEgKFFpbnZhbGlkX2Z1bmN0aW9uLCBmdW4pOworCisgIHJldHVybiBG Y29ucyAobWFrZV9udW1iZXIgKG1pbmFyZ3MpLCBtYWtlX251bWJlciAobWF4YXJncykpOworfQor CisKIERFRlVOICgiZmV0Y2gtYnl0ZWNvZGUiLCBGZmV0Y2hfYnl0ZWNvZGUsIFNmZXRjaF9ieXRl Y29kZSwKICAgICAgICAxLCAxLCAwLAogICAgICAgIGRvYzog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