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

  • Home
  • SEARCH
  • 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 872329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:46:10+00:00 2026-05-15T10:46:10+00:00

Here it is a strange function in Scheme: (define f (call/cc (lambda (x) x)

  • 0

Here it is a strange function in Scheme:

(define f
(call/cc
(lambda (x) x) ) )

(((f ‘f) f) 1 )

When f is called in the command line, the result displayed is f .
What is the explanation of this mechanism ?..

Thanks!

  • 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-05-15T10:46:10+00:00Added an answer on May 15, 2026 at 10:46 am

    You’ve just stumbled upon ‘continuations’, possibly the hardest thing of Scheme to understand.

    call/cc is an abbreviation for call-with-current-continuation, what the procedure does is it takes a single argument function as its own argument, and calls it with the current ‘continuation’.

    So what’s a continuation? That’s infamously hard to explain and you should probably google it to get a better explanation than mine. But a continuation is simply a function of one argument, whose body represents a certain ‘continuation’ of a value.

    Like, when we have (+ 2 (* 2 exp)) with exp being a random expression, if we evaluate that expression there is a ‘continuation’ waiting for that result, a place where evaluation continues, if it evaluates to 3 for instance, it inserts that value into the expression (* 2 3) and goes on from there with the next ‘continuation’, or the place where evaluation continues, which is (+ 2 ...).

    In almost all contexts of programming languages, the place where computation continues with the value is the same place as it started, though the return statement in many languages is a key counterexample, the continuation is at a totally different place than the return statement itself.

    In Scheme, you have direct control over your continuations, you can ‘capture’ them like done there. What f does is nothing more than evaluate to the current continuation, after all, when (lambda (x) x) is called with the current continuation, it just evaluates to it, so the entire function body does. As I said, continuations are functions themselves whose body can just be seen as the continuation they are to capture, which was famously shown by the designers of Scheme, that continuations are simply just lambda abstractions.

    So in the code f first evaluates to the continuation it was called in. Then this continuation as a function is applied to 'f (a symbol). This means that that symbol is brought back to that continuation, where it is evaluated again as a symbol, to reveal the function it is bound to, which again is called with a symbol as its argument, which is finally displayed.

    Kind of mind boggling, if you’ve seen the film ‘primer’, maybe this explains it:

    http://thisdomainisirrelevant.net/1047

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange error here, I think. Fatal error: Call to undefined function
I got a strange segmentation fault when executing recv() function of . Here's the
I have a strange behavior with PHP system function. In this php script there
Here's an interesting problem: I have some jQuery that looks like this: $(document).ready(function() {
Here's some strange javascript behavior of the map function in Firefox. During an error
Having strange problem with str_replace. Here's my code: function replace_text($text) { $array = array(
I got a strange behavior from the mail function in php here is the
Please help! I have a strange issue here. DEMO The issue in this gallery
Here is my most simple code: var this_version =null; this.timervar = setTimeout(function () {
I have a strange scenario here. I have this code: // For checking if

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.