From: <tomas@tuxteam.de>
To: guile-user@gnu.org
Subject: Re: Applicable structs and vtables
Date: Sat, 14 Aug 2021 08:53:16 +0200 [thread overview]
Message-ID: <20210814065316.GB11671@tuxteam.de> (raw)
In-Reply-To: <598960ee-3baf-dca7-ed88-e128d5eb2fe9@posteo.de>
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
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:
>
> <arity-function: min: 1, max: 3, function: (some lambda here)>
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2021-08-14 6:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 20:33 Applicable structs and vtables Zelphir Kaltstahl
2021-08-14 6:53 ` tomas [this message]
2021-08-14 9:19 ` Zelphir Kaltstahl
2021-08-14 10:40 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210814065316.GB11671@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).