Re: SRFI 102 Arthur A. Gleckler 22 Sep 2009 21:25 UTC
> One benefit of the current proposal is that it can handle procedures > constructed with `case-lambda'. Under the above proposal, it's not possible > to produce an error message that says something like: "procedure f expects > 1, 5 or 6 or more arguments, given 2: a, b". Oh, sorry. Somehow, I didn't see the fourth type of data that `procedure-arity' might return: a list. I would still prefer not to have to construct a first-class object in order to ask most questions about arity, and also would prefer not to have to do so much type dispatch on the value returned by `procedure-arity'. How about this?: ; Is arity information available for this procedure? (arity-available? procedure) ==> Boolean ; Return #t iff procedure accepts k or more arguments. ; It is an error to call this if `arity-available?' would return #f. (arity-at-least? procedure k) ==> Boolean ; Return all possible arities for this procedure as a list of ; integers. If rest arguments are supported, the last number is the ; number of arguments above which all possible arities are allowed. ; In other words, if a procedure accepts either 1 or 5 or more ; arguments, return the list (1 5). The caller can tell that more ; than 5 arguments would be accepted by calling `(arity-at-least? ; procedure 5)'. ; It is an error to call this if `arity-available?' would return ; #f. (all-arities procedure) ==> list of non-negative integers ; Return #t iff `procedure' would accept `integer' arguments. ; It is an error to call this if `arity-available?' would return #f. (arity-includes? procedure k) ==> Boolean Each of these procedures returns just one type of value, so no type dispatch is necessary. Also, no allocation is necessary except in the `all-arities' case, where it seems unavoidable.