What is an uninvokable procedure -- and how/why?

Reading TIL: Partial application and currying aren't the same made me look at the implementation of curry.

A helper function it uses:

  ; arity-mask? -> (or/c exact-nonnegative-integer? +inf.0 #f)
  ;
  ; Calculates the maximum number of arguments a function with the given arity may be applied to. If
  ; an unbounded number of arguments are permitted, returns +inf.0. If no number of arguments is valid
  ; (that is, the procedure is uninvokable), returns #f.
  (define (arity-upper-bound mask)
    (cond
      [(eqv? mask 0) #f]
      [(negative? mask) +inf.0]
      [else (sub1 (integer-length mask))]))

On first read, I nodded along. A minute later... wait. What exactly is an "uninvokable procedure", for which no number of arguments is valid (not even zero)?

It sounds like a procedure that can't be invoked/called/applied -- that doing so is an error.

Is that correct? If so, how do you create such a procedure, and why would you?

3 Likes

It looks like how you can create one using procedure-reduce-arity (or the -mask flavor). Still not sure about the why.

1 Like

Here's an example:

(define f (case-lambda))
3 Likes

Thanks for that example!

Naively I would have guessed instead that (case-lambda) is an error, and there's no need for such a thing as an uninvokable procedure.

1 Like