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
signature.asc
Description: Digital signature
