Skip to main content

Questions tagged [callcc]

call-with-current-continuation (abbreviated as call/cc) is a control operator in functional programming

1 vote
1 answer
89 views

How to get the stack pointer and return address and restore them to a previous state

I'm trying to implement a poor man's call with current continuation for a program written in C. I can "easily" access and memcpy the relevant part of the C stack (obviously, that's not ...
Stefan's user avatar
  • 28.2k
2 votes
1 answer
169 views

Get current contiuation in Scala

Haskell has a function for getting the current continuation getCC = callCC (\c -> let x = c x in return x) How to write a similar function in Scala? E.g. function callCC presents in cats.ContT. ...
Sergey Sviridov's user avatar
0 votes
1 answer
95 views

How to interpret (call/cc call/cc)?

I'm familiar with using call/cc to interpret CPS programs in a direct style: (define (f return) ...
Aly's user avatar
  • 883
1 vote
2 answers
107 views

why is `(((call/cc (lambda (k) k)) (lambda (x) x)) "HEY!")` evaluated to "HEY!"?

I am reading The scheme programming language and seeing this example in continuation section: (((call/cc (lambda (k) k)) (lambda (x) x)) "HEY!") => "HEY!" I cannot figure out ...
happybzy's user avatar
2 votes
1 answer
382 views

call/cc example in JavaScript

Now that ES6 supports Proper Tail Call, and since according to Wikipedia, "In any language which supports closures and proper tail calls, it is possible to write programs in continuation-passing ...
CidTori's user avatar
  • 399
1 vote
2 answers
2k views

Task execution pause/resume in Rust async? (tokio)

How can I pause an async task in Rust? Swift has withCheckedContinuation(function:_:) that pauses current task and returns saved context that can be resumed at desired time. (a.k.a. call/cc) tokio ...
eonil's user avatar
  • 85.2k
1 vote
3 answers
558 views

Understanding Implementation of call-with-continuation

I'm trying to understand a scheme procedure written in python code: def callcc(proc): "Call proc with current continuation; escape only" ball = RuntimeWarning("Sorry, can't ...
carl.hiass's user avatar
  • 1,706
5 votes
2 answers
110 views

Palindrome and Danvy's remark on direct style

Here is some code deciding whether a list is a palindrome in n+1 comparisons, in "direct style" pal_d1 :: Eq a => [a] -> Bool pal_d1 l = let (r,_) = walk l l in r where walk l ...
nicolas's user avatar
  • 9,725
2 votes
1 answer
640 views

call cc example racket

I'm analyzing this code regarding the use of call/cc. This function is kind of mystical, and it's quite complicated to fully understand. I really cannot understand how this code is working. Below is ...
Walter's user avatar
  • 125
1 vote
0 answers
106 views

What is the J operator and is it the same as call/cc?

I have heard of the "J operator" or "program point operator", when researching about ISWIM. I would like to know what it is. The Wikipedia article for it is very vague: In ...
R Z's user avatar
  • 480
1 vote
1 answer
81 views

how to analyze the equivalent receiver in call/cc?

I am reading the book Scheme and the Art of Programming, but cannot think of an answer to the following question: If r is (escaper (lambda (continuation) (continuation body)) in (... (call/cc r) .....
yanpengl's user avatar
  • 220
1 vote
0 answers
159 views

Why using goto is regarded as bad practice, but call/cc isn't?

I am currently learning the concept of continuations. I am struggling with understanding why direct control flow manipulation by e.g. goto command is a bad practice, but doing so using call/cc is just ...
M. Twarog's user avatar
  • 2,575
0 votes
1 answer
123 views

Clarification on callCC

My background is Javascript, Python & a bit of Haskell. Hi I am new to Scheme (1 day old). I want to understand the difference between below 2 code snippets. (define onePlus (lambda (v) (+ 1 v))) ...
Pawan Kumar's user avatar
  • 1,493
1 vote
2 answers
372 views

Is CallCC an improved version of goto?

My background is Javascript, Python & a bit of Haskell. I am trying to understand callCC, there are many explanations but I can't find them trivial & I came across this https://www.cs.bham.ac....
Pawan Kumar's user avatar
  • 1,493
1 vote
2 answers
300 views

Which simplest evaluation model explains call/cc?

TL;DR: What does call/cc do, (semi-)formally speaking? The long version: I'm vaguely familiar with continuations and call/cc, but I don't have a strong formal understanding. I would like one. In the ...
Jonas Kölker's user avatar

15 30 50 per page
1
2 3 4 5 6