Questions tagged [continuation]

53 questions
22
votes
4 answers

Comments in continuation lines

Say I have a multiline command: if 2>1 \ and 3>2: print True In an if block, I can add a comment next to one of the conditions by using parentheses to wrap the lines: if (2>1 #my comment and 3>2): print True And, in fact, it is aligned…
fedorqui
  • 275,237
  • 103
  • 548
  • 598
21
votes
2 answers

Why can't there be an instance of MonadFix for the continuation monad?

How can we prove that the continuation monad has no valid instance of MonadFix?
Petr
  • 62,528
  • 13
  • 153
  • 317
19
votes
7 answers

syntaxerror: "unexpected character after line continuation character in python" math

I am having problems with this Python program I am creating to do maths, working out and so solutions but I'm getting the syntaxerror: "unexpected character after line continuation character in python" this is my code print("Length between sides:…
Arcticfoxx
  • 421
  • 1
  • 5
  • 11
19
votes
1 answer

Sphinx: Resume list numbering after a note section

Consider the following list in ReStructuredText: Broken list example ------------------- #. First do spam #. Then do ``eggs`` .. note:: Nobody expects the Spanish Inquisistion #. The list restarts after the note When the list is compiled…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
14
votes
1 answer

C# await vs continuations: not quite the same?

After reading Eric Lippert’s answer I got the impression that await and call/cc are pretty much two sides of the same coin, with at most syntactic differences. However, upon trying to actually implement call/cc in C# 5, I ran into a problem: either…
Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
14
votes
4 answers

What is the proper way to propagate exceptions in continuation chains?

What is the proper way to propagate exceptions in continuation chains? t.ContinueWith(t2 => { if(t2.Exception != null) throw t2.Exception; /* Other async code. */ }) .ContinueWith(/*...*/); t.ContinueWith(t2 => { …
ronag
  • 49,529
  • 25
  • 126
  • 221
13
votes
7 answers

Objective C - how to programmatically stop execution for debugging, while allowing continuation?

I have had success getting my debug builds to stop execution when a condition is programmatically specified, using the standard NSAssert(condition_which_should_evaluate_true, @"error message") statement in Objective C, and adding in an "All…
Merk
  • 1,441
  • 1
  • 15
  • 28
12
votes
1 answer

Trying to apply CPS to an interpreter

I'm trying to use CPS to simplify control-flow implementation in my Python interpreter. Specifically, when implementing return/break/continue, I have to store state and unwind manually, which is tedious. I've read that it's extraordinarily tricky to…
Matt Green
  • 2,032
  • 2
  • 22
  • 36
5
votes
0 answers

Why in Ruby 1.9 Continuations are evil?

I am relative new in Ruby world. And I don't know, what to think. In 'The Ruby Programming Language' I read I shouldn't use Continuations in new code and use Fibers instead. I found this presentation (from 2008)…
guest
  • 1,696
  • 4
  • 20
  • 31
5
votes
2 answers

Continuation monad for a yield/await function in Haskell

I want to create an automata type with a type like this: newtype Auto i o = Auto {runAuto :: i -> (o, Auto i o)} I know this is the type of the Automata arrow, but I'm not looking for an arrow. I want to make this a monad, so presumably its going…
Paul Johnson
  • 17,438
  • 3
  • 42
  • 59
5
votes
1 answer

How does the Delay exactly works in continuation monad to prevent stackoverflow?

This is a reference question to this: StackOverflow in continuation monad with whom I played a little and would need a few clarifications. 1) I suppose this: member this.Delay(mk) = fun c -> mk () c makes the behavior in computational workflow do…
tomasK
  • 358
  • 1
  • 3
  • 14
5
votes
2 answers

Scheme: how does a nested call/cc work for a coroutine?

I am looking at the following example for a coroutine from http://community.schemewiki.org/?call-with-current-continuation: (define (hefty-computation do-other-stuff) (let loop ((n 5)) (display "Hefty computation: ") (display n)…
hxngsun
  • 105
  • 6
4
votes
1 answer

Scheme- using continuations

So I THINK I understand how continuations basically work in Scheme, but I'm having trouble figuring out how to use it instead of recursion. We are given working code for make-matcher (just basic pattern matching) that already does everything we want…
T T
  • 261
  • 5
  • 16
3
votes
1 answer

SML - collecting words in a trie using continuations

I have a datatype trie = Node of char * (trie ref) list | Empty And I want to collect all the words in the trie, using these two mutually recursive functions: words_in_trie: trie -> (char list list -> 'a) -> 'a all_words: trie ref list -> (char…
Lanaru
  • 9,421
  • 7
  • 38
  • 64
3
votes
4 answers

Is it make sense to make IO an instance of MonadCont?

Obviously MonadConts is more restricted and gives more power than plain Monads, thanks to its callCC. This means less instances of it, and more you can do with it. When look at defined instances of MonadCont, it looks like everything listed there…
Earth Engine
  • 10,048
  • 5
  • 48
  • 78
1
2 3 4