[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applicable structs and vtables

From: tomas
Subject: Re: Applicable structs and vtables
Date: Sat, 14 Aug 2021 08:53:16 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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 ;-)

 - t

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]