# Re: Revised straw proposal for heuristic info

```
From dyb@cs.indiana.edu Tue May 14 14:50:53 1996
From: "R. Kent Dybvig" <dyb@cs.indiana.edu>
To: will@ccs.neu.edu
Subject: Re: Revised straw proposal for heuristic info
Cc: rrrs-authors@martigny.ai.mit.edu

> > Why limit the list in the third case to exact non-negative integers?
> > By doing so, procedure-arity can't precisely describe procedures that
> > accept, for example, 1 or 2+ arguments.

> (procedure-arity _proc_)
>
>   Returns information about the arity of _proc_.  If the result
>   is #F, then no information is available.  If the result
>   is an exact non-negative integer k, then _proc_ requires
>   exactly k arguments.  If the result is an inexact non-negative
>   integer n, then _proc_ requires n or more arguments.  If the
>   result is a pair, then it is a list of non-negative integers,
>   each of which indicates a number of arguments that will be
>   accepted by _proc_; the list is not necessarily exhaustive.

There are lots of other interesting representations.  Here is one:

The result is a list of boolean values, whose j'th element (zero origin)
is #t iff the procedure will accept j arguments.

This representation is quite flexible.  For example, the requirement
of 0, 1, 4, 5, or 7 arguments is represented as:

(#t #t #f #f #t #t #f #t)

The case of "n or more" can be handled by circular lists.  For example,
"3 or more arguments" can be represented by (excuse the Common Lisp notation):

(#f #f #f . #43=(#t . #43#))

and the case of "at least two arguments followed by any number of triples of
arguments" is represented as

(#f #f . #49=(#t #f #f . #49#))

Best of all, it doesn't use any numbers.  Don't complain to me that it
takes too long too cdr down the list---you probably have a list of
arguments in hand, anyway, that you're going to call LENGTH on,
so matching the argument list against the procedure-arity pattern
imposes only a constant factor overhead.

You can still use #f to mean "no information".

--Guy

```