[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Non-stack-copying call-with-current-continuation?
From: |
Andreas Rottmann |
Subject: |
Re: Non-stack-copying call-with-current-continuation? |
Date: |
Sat, 03 Mar 2012 06:04:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) |
David Kastrup <address@hidden> writes:
> Noah Lavine <address@hidden> writes:
>
>> Hello,
>>
>>> Sure, but things like gensym and make-prompt-tag (and (list '()) for
>>> creating an eq?-unique object) are artificial hygiene coming at a cost
>>> in symbol table and symbol generation time rather than "lexical"
>>> hygiene. They need _extra_ work, whereas the
>>> call-with-current-continuation approach needed _less_ work. Basically I
>>> want something like call-with-single-continuation that will only allow
>>> one return (and any dynwind out counts and should work if it is the
>>> first, so it is not exactly equivalent to using
>>> with-continuation-barrier) and come without the stack-copying cost of
>>> call-with-current-continuation.
>>
>> I agree that it's not pretty. We have hygienic macros so we don't have
>> to use gensym, after all. But I don't know of a better way.
>
> Well, to wrap this up: the manual (not current) states
>
> It is traditional in Scheme to implement exception systems using
> `call-with-current-continuation'. Continuations (*note
> Continuations::) are such a powerful concept that any other control
> mechanism -- including `catch' and `throw' -- can be implemented in
> terms of them.
>
> [...]
>
> The more targeted mechanism provided by `catch' and `throw' does not
> need to save and restore the C stack because the `throw' always jumps
> to a location higher up the stack of the code that executes the
> `throw'. Therefore Guile implements the `catch' and `throw' primitives
> independently of `call-with-current-continuation', in a way that takes
> advantage of this _upwards only_ nature of exceptions.
>
>
> I think that using something like "call-with-single-continuation" as the
> underlying primitive would make Guile quite more similar to
> "traditional" systems in the code base. It would also provide a
> minimally-invasive tool for tuning existing code based on
> call-with-current-continuation in case that the stack copying semantics
> are _not_ required. Definitely more Schemeish than stuff like, uh,
> prompts?
>
Just to throw my two cents in: Racket (and probably other Schemes)
provide this primitive under the name call-with-escape-continuation
(call/ec):
http://docs.racket-lang.org/reference/cont.html?q=call/ec#%28def._%28%28quote._~23~25kernel%29._call-with-escape-continuation%29%29
Regards, Rotty
--
Andreas Rottmann -- <http://rotty.yi.org/>
- Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/01
- Re: Non-stack-copying call-with-current-continuation?, Noah Lavine, 2012/03/01
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/01
- Re: Non-stack-copying call-with-current-continuation?, Noah Lavine, 2012/03/01
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/01
- Re: Non-stack-copying call-with-current-continuation?, Noah Lavine, 2012/03/01
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/02
- Re: Non-stack-copying call-with-current-continuation?, Andreas Rottmann, 2012/03/03
- Re: Non-stack-copying call-with-current-continuation?,
Andreas Rottmann <=
- Re: Non-stack-copying call-with-current-continuation?, Andy Wingo, 2012/03/03
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, Andy Wingo, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, Andy Wingo, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, Mark H Weaver, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, Mark H Weaver, 2012/03/04
- Re: Non-stack-copying call-with-current-continuation?, David Kastrup, 2012/03/04
Re: Non-stack-copying call-with-current-continuation?, Nala Ginrut, 2012/03/01