Questions tagged [callcc]
call-with-current-continuation (abbreviated as call/cc) is a control operator in functional programming
callcc
88
questions
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 ...
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. ...
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) ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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) .....
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 ...
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)))
...
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....
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 ...