Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:30:58+00:00 2026-06-07T09:30:58+00:00

Consider the following code: (call-with-values (lambda () (call/cc (lambda (k) (k k k)))) (lambda

  • 0

Consider the following code:

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

It’s pretty obvious here that the continuation at the point of the call/cc call is the lambda on the right-hand side, so its arity should be 2. However, the return value of the above (in Racket) is (arity-at-least 0) instead.

Indeed, running similar code in Guile (substituting procedure-minimum-arity for procedure-arity) shows that the continuation also supposedly allows any number of arguments, even though it’s pretty clearly not the case.

So, why is that? As far as I understand (correct me if my understanding is wrong), the arity of a continuation is pretty straightforward: it’s 1 except in the context of call-with-values, in which case it’s whatever the arity of the right-hand-side lambda is. (Which, granted, can be complicated if it’s a case-lambda or the like, but no more complicated than if you were calling (procedure-arity (case-lambda ...)) directly.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:31:00+00:00Added an answer on June 7, 2026 at 9:31 am

    A simpler way to see the same is:

    (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)))
    

    And for your question — it’s clear in the first case that the continuation expects two inputs, but cases like that are not too common. Eg, they’re usually such examples, whereas “real code” would use define-values or have some unknown continuation, where the continuations that call/cc creates can have different arities depending on the context that they were created at. This means that there’s not much point in trying to figure out these rare cases where the continuation’s arity is known.

    Footnote:

    ;; nonsensical, but shows the point
    (define (foo) (call/cc (λ (x) x)))
    (define x (foo))
    (define-values [y z] (foo))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider the following code: type TFoo1 = class public procedure DoSomething1; end; TFoo2
Consider the following code // BOGP.cpp : Defines the entry point for the console
What am I doing wrong here ? /* * Consider the following pseudo code
Consider the following code enum HorizontalAlignment { Left, Middle, Right }; enum VerticleAlignment {
Consider following code: My problem is: 1) I can't seem to cast the errors
Consider following code: enum size = 16; double[size] arr1 = [...]; double[size] arr2 =
Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { //
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Consider the following code: template <class x1, class x2 = int*> struct CoreTemplate {
Consider the following code: public interface A { public A another(); } public interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.