From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Procedure arity and documentation Date: Wed, 26 May 2021 19:33:28 +0000 Message-ID: <42849034-24cb-912a-41b8-4e00b8bfac59@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1162"; mail-complaints-to="usenet@ciao.gmane.io" To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed May 26 21:34:07 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1llzI7-000AZX-3Y for guile-user@m.gmane-mx.org; Wed, 26 May 2021 21:34:07 +0200 Original-Received: from localhost ([::1]:56392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llzI5-0007vS-2L for guile-user@m.gmane-mx.org; Wed, 26 May 2021 15:34:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llzHc-0007pR-Qp for guile-user@gnu.org; Wed, 26 May 2021 15:33:36 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:40133) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llzHa-0001pZ-Da for guile-user@gnu.org; Wed, 26 May 2021 15:33:36 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 76B032400FC for ; Wed, 26 May 2021 21:33:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1622057609; bh=jmyFgeCj8aRH/x/bWsD0H3BRQdWjy8IjFpJmMDTKWCM=; h=To:From:Subject:Date:From; b=BtDcdnWxJaA6iqpTFX5af+uUdodFzxHLqPqemUI8u32HOp5pLAUJJM0tnfp0xJBYk xY3Ba7Wozb5BdnuJMwsCOuegobplAXMZ8BxzFRw94OLdDhaebRd+a0tYneZEqC8Lvs vKcUBP2pr33o2g9QARW85WU/bCIBtNPL61B8Reg6WY1GyIKT1mqXNYlFnqF8Y5lVUz 2a61WxHTOAuLXD2UrLOSPOOjy5RpszEsIfvREJsWhcvRrRLq3zXgEMvttz8iirmFgl jJ+GuYsVCU1/XnBLCvgZL/pAlNDkOEIpZfnlV2oVjkizqL0X8UdbwMm4B3LwZaFsrK 923r8pZVYPieQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Fr1MX6yCBz6tmJ for ; Wed, 26 May 2021 21:33:28 +0200 (CEST) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17537 Archived-At: Hello Guile users! Today I found the procedure `procedure-minimum-arity`, while tab-completing in Geiser. I then looked for its documentation in the Guile manual, but could not find anything about it. (help procedure-minimum-arity) shows: ~~~~ scheme@(guile-user)> (help procedure-minimum-arity) `procedure-minimum-arity' is a procedure in the (guile) module. - Scheme Procedure: procedure-minimum-arity proc Return the "minimum arity" of a procedure. If the procedure has only one arity, that arity is returned as a list of three values: the number of required arguments, the number of optional arguments, and a boolean indicating whether or not the procedure takes rest arguments. For a case-lambda procedure, the arity returned is the one with the lowest minimum number of arguments, and the highest maximum number of arguments. If it was not possible to determine the arity of the procedure, `#f' is returned. ~~~~ Which helps a lot. I could not understand the procedure's output before that. Why is the procedure named "minimum", when it also gives the number of optional arguments and whether it accepts rest arguments? Is this procedure official API, or is it merely exposed and I should not be using it? I am currently reading a book, which uses MIT/GNU Scheme and there exist `procedure-arity-min` and `procedure-arity-max`. If there is `min`, then I would expect `max` to be also there. I was a bit confused with Guile only having `minimum`, but `minimum` not actually being only the minimum, but also option and rest, which enables one to calculate the maximum. I also found that the following errors: ~~~~ scheme@(guile-user)> (import (system vm program)) scheme@(guile-user)> (arity:nreq (program-arities (lambda (a b) (+ a b)))) ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: program-arities Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. ~~~~ Although the manual says: > The normal case is that a procedure has one arity. For example, (lambda (x) x), takes one required argument, and that’s it. One could access that number of required arguments via (arity:nreq (program-arities (lambda (x) x))). Similarly, arity:nopt gets the number of optional arguments, and arity:rest? returns a true value if the procedure has a rest arg. -- https://www.gnu.org/software/guile/manual/guile.html#Compiled-Procedures Is that a bug, or is it, because I am trying to use it in the REPL and there my procedure is not compiled? Best regards, Zelphir -- repositories: https://notabug.org/ZelphirKaltstahl