An attempt to define the meaning of procedure arity Marc Nieper-Wißkirchen (17 Jun 2020 21:30 UTC)
Re: An attempt to define the meaning of procedure arity Alex Shinn (17 Jun 2020 22:10 UTC)
Re: An attempt to define the meaning of procedure arity Marc Nieper-Wißkirchen (18 Jun 2020 06:08 UTC)

An attempt to define the meaning of procedure arity Marc Nieper-Wißkirchen 17 Jun 2020 21:30 UTC

After I have argued that the current wording of SRFI 191 does not make
sense for a general R7RS implementation, here is a constructive
attempt to define the meaning of procedure arity (although I agree
with Kent Dybvig and Alex Shinn that it is probably not a good idea
for standardization):

1. Add the following to the end of 4.1.4 (in the R7RS): "Each
procedure created as the result of evaluating a lambda expression has
a well-defined arity, which is an integer interpreted as a bitset
whose nth bit is set if and only if the procedure *formally* can take
n arguments."

2. Add a similar text in 4.2.9. for case-lambda.

3. Add further: "The arity of procedures, which are created through
any other means, is implementation-dependent."

4. Formally define the arity of the standard library procedures (which
are not necessarily the result of evaluating a lambda or case-lambda
expression), e.g. by referring to their entry format.

5. Define procedure-arity-mask as a procedure that takes a procedure
PROC as an argument and returns an integer N such that (bitset-and A
N) evaluates to A, when A is the formal arity (as defined above) of
PROC.  The exact value of N is implementation-dependent.  (In other
words, N may have more bits sets than A.)

Marc