Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #692
| From | torbenm@diku.dk (Torben Ægidius Mogensen) |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: grab the continuation at specific point in a program |
| Date | 2012-06-11 13:22 +0200 |
| Organization | SunSITE.dk - Supporting Open source |
| Message-ID | <12-06-031@comp.compilers> (permalink) |
| References | <12-06-025@comp.compilers> |
Yakov Z <yakov@clickgrab.net> writes: > AFAIU, to grab the continuation at specific point in a program I still > have to do CPS conversion of the whole program (because CPS is global) > I then end up with a lot of uninteresting continuations (like for > constants and variables etc.) > > If I want to get rid of those and leave only one "at that point" > continuation (with everything on which it depends upward the call > path) I need to perform another transformation. Do you know if > approaches exist to do the above in one run? You don't need CPS conversion if you can get access to the computation state -- specifically the function call stack. The continuation is in that case "just" a copy of the call stack. This makes it rather costly to grab or call a continuation, but there is next to no cost for programs not using call/cc. If the call "stack" is represented by a linked list, grabbing and using continuations is cheaper, but it means you have to GC the call frames instead of unstacking them, which may or may not be more expensive. CPS transformation gives essentially the same effect, as closures are typically heap allocated. In all cases, continuations are a bit questionable if you have mutable variables: When a continuation is called, do you want to return these to the state they had at the time the continuation was grabbed, or do they keep the values they have at the time of the call? Is there a difference between register-allocated variables, stack-alloctaed variables and heap-allocated variables? The answers to these questions may limit the choices of how to implement continuations. Torben
Back to comp.compilers | Previous | Next — Previous in thread | Find similar
grab the continuation at specific point in a program Yakov Z <yakov@clickgrab.net> - 2012-06-09 10:07 -0700 Re: grab the continuation at specific point in a program torbenm@diku.dk (Torben Ægidius Mogensen) - 2012-06-11 13:22 +0200
csiph-web