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: Re: Applicable structs and vtables Date: Sat, 14 Aug 2021 09:19:49 +0000 Message-ID: <4f308868-fb6b-6557-76a8-1c3481983a48@posteo.de> References: <598960ee-3baf-dca7-ed88-e128d5eb2fe9@posteo.de> <20210814065316.GB11671@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1704"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Guile User To: tomas@tuxteam.de Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Aug 14 11:20:06 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 1mEppm-0000G0-LC for guile-user@m.gmane-mx.org; Sat, 14 Aug 2021 11:20:06 +0200 Original-Received: from localhost ([::1]:55324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEppl-0000W9-JV for guile-user@m.gmane-mx.org; Sat, 14 Aug 2021 05:20:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEppb-0000Vz-HU for guile-user@gnu.org; Sat, 14 Aug 2021 05:19:55 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:34957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEppZ-00087Z-87 for guile-user@gnu.org; Sat, 14 Aug 2021 05:19:55 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 0877E240101 for ; Sat, 14 Aug 2021 11:19:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1628932791; bh=WRxjb+mDFaYhIJobbkMZlIzHpCKS3XEBv3SzWozSkHA=; h=Subject:To:From:Cc:Date:From; b=ATepyUvI3Wuj5Xx+BuZn6/WE0EbW1KK8ESnFIFNs+bE1+20EGbjSnA/kXaajnPnxt 5Yx2R7uSV/GwBUtI81XrgQZqwRLuJliGWew5YQlubhO+6hqVcpr1spJOKGchV9jG2h osK8YRI6wtNyAdFAbZ+g9wVVcb6VlllfiTjbBLxrYwUqEjdMVa09m/gPk5XEu1Ibzk oU31XfQKcoJ20Xt89F+zS0h1NQauU79KseSuQsuPNO9oYRBapQ1ydhzWVg+h11w23C SaXYu0+IQZnbmSaV+m6GmDrlxEmQ6hXh6ZTHeIvgyKZPVy8/taEGZWEy0+0DQmonuc SAjDu18O8lRWQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GmvyZ2NMyz9rxH; Sat, 14 Aug 2021 11:19:50 +0200 (CEST) In-Reply-To: <20210814065316.GB11671@tuxteam.de> 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_H2=-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:17685 Archived-At: Hi Tomas! Ultimately I need the minimum and maximum arity of functions (not sure if anything in between is needed, but I think not). Minimum and knowing, that rest arguments exist is not sufficient. The exact maximum number of arguments is what I require, even if it turns out to be infinity or some implementation limit. Trying to give an example: It is a learning project, about function combinators and there are combinators, which could for example return functions, which split their arguments into 2 groups of arguments, 1 group for each combined function. Lets say the combined function h takes k, k+1 or k+2 arguments. Out of k arguments the first function (f) of the combined functions could take n arguments leaving k-n arguments for the second function (g). However, if k+1 arguments were provided to h or k+2 arguments, then then the second function (g) could take k-n+1 or k-n+2 arguments, simply because more arguments are remaining for the second function. To implement checks for correct number of arguments at runtime (assertions), I need, I think, the exact maximum number of arguments and not only the information, that there can be rest arguments. The reference manual has more about "program arities" (https://www.gnu.org/software/guile/manual/guile.html#Compiled-Procedures ), but that API is not working currently, as found out in a previous thread on this mailing list: https://lists.gnu.org/archive/html/guile-user/2021-05/msg00044.html . I think only the one function you mention is currently working. While that API is not properly working, I think "callable objects" could be a solution to my problem. Thanks for your reply! Zelphir On 8/14/21 8:53 AM, tomas@tuxteam.de wrote: > On Fri, Aug 13, 2021 at 08:33:33PM +0000, Zelphir Kaltstahl wrote: >> Hi Guile users, >> >> I have some code, in which I wrap procedures in a record, which contains >> members, which express the arity of the procedures. For example one struct be: >> >> > I don't know whether what you're after is about generalising what a > function can be ("callable objects" or similar), or if procedure > arity introspection at run time is your ultimate goal. > > In the second case, there is `procedure-minimum-arity', which might > already cater to your wishes :-) > > (procedure-minimum-arity cons) ; takes two arguments, no "rest" > => (2 0 #f) > (procedure-minimum-arity +) ; takes at least 0, takes "rest" > => (0 2 #t) > (let ((foo (lambda (x y . z) ('some-result)))) ; DIY > (procedure-minimum-arity foo)) ; at least 2, with "rest" > => (2 0 #t) > > I don't know (yet) what the middle number is for, though ;-) > > Cheers > - t -- repositories: https://notabug.org/ZelphirKaltstahl