[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
manipulating continuations
From: |
Tomtom |
Subject: |
manipulating continuations |
Date: |
Sat, 12 Feb 2011 09:35:06 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101227 Icedove/3.0.11 |
Hello list
First of all, I'm new to scheme and guile - started using them a few
days ago for a project. So here we go: this is the bit of code that
causing me troubles:
(define (foo)
(call/cc
(lambda (return)
(display "first part")
(newline)
(call/cc
(lambda (cont)
(return cont)))
(display "second part")
(newline))))
Basically, I use call/cc to stop the procedure foo after printing "first
part" and return a continuation. Then, if I call this continuation it
prints "second part" and ends. To test this code, I did this:
guile> (define c (foo))
first part
guile> (c)
second part
yay, it works. But now, what if I want to run the continuation directly,
rather than storing it and calling it later ? This is what I get:
guile> ((foo))
first part
second part
Backtrace:
In current input:
15: 0* [#<unspecified>]
<unnamed port>:15:1: In expression ((foo)):
<unnamed port>:15:1: Wrong type to apply: #<unspecified>
ABORT: (misc-error)
There. I don't understand why I get this error message.
Cheers
Tom