Why don't sequels have a useful entity?

Consider the following code:

(call-with-values
    (lambda ()
      (call/cc (lambda (k)
         (k k k))))
  (lambda (x y)
    (procedure-arity y)))

Here it is pretty obvious that the continuation at the point of call call/ccis a lambda on the right side, so its arity should be 2. However, the return value above (in Racket) is equal (arity-at-least 0).

Indeed, running the same code in Guile (substitution procedure-minimum-arityfor procedure-arity) shows that the continuation also supposedly allows any number of arguments, although this is clearly not the case.

So why? As far as I understand (correct me if my understanding is wrong), the arity of the continuation is quite simple: it is 1, except for the context call-with-values, and in this case it does not matter for the lambda on the right side. (Which provided can be complicated if it case-lambdaor the like, but no more complex than if you directly called (procedure-arity (case-lambda ...)).)

+5
source share
1 answer

A simpler way to see the same thing:

(call-with-values
  (lambda () (error 'arity "~v" (procedure-arity (call/cc (λ (k) k)))))
  (lambda (x y) (procedure-arity y)))

and even simpler:

(procedure-arity (call/cc (λ (x) x)))

- , , . , , " " define-values - , , call/cc, , . , , .

:

;; nonsensical, but shows the point
(define (foo) (call/cc (λ (x) x)))
(define x (foo))
(define-values [y z] (foo))
+2

All Articles