[racket] coding with continuations

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Mon Oct 27 22:08:14 EDT 2014

On Mon, Oct 27, 2014 at 01:08:24PM -0500, Matthias Felleisen wrote:
> 
> In my 30 year career as a Schemer and Racketeer, I have found 
> one successful use for (upward) continuations in the world of 
> search, to be precise so-called "intelligent search". That's a
> 1970s concept from AI. You have a complex search space and a decision
> functions on which subspaces to search next given certain conditions
> on the current state of the search. At each decision point, you compute
> the next best choice, which includes all backtracking points. All 
> subspaces that aren't searched are marked as such backtracking points, 
> which is information about the space plus a continuation, which knows
> how to resume the search in this world. Then you enter the next subsapce, 
> which is equivalent to throwing a continuation. 

Yes, that's the kind of thing  had in mind.

Are there any examples or other information available about it, or 
is it time to start reinventing t from scratch.

Maybe Steele had something?  He did invent Scheme in the context of a 
lab that was trying to invent AI languages, which at that tie seemed to 
mean intelligent search.

> 
> I know that there are many papers that use continuations for searches. 
> For most of these examples and most implementations, the algorithm is 
> neither as performant as one that passes continuations via closures 
> nor any easier to understand than one that explicitly manipulates 
> success and fail continuations. 
> 
> My judgement for the second point is different when this kind of code 
> is what a macro expands into and continuations are highly performant. 

Macro expansion, or something like it, is probably the way I'd do it.

> 
> ----------------------------------------------------------------
> 
> Having said that, I do wish to emphasize that continuations are 
> useful in other contexts and every time I am about ready to throw
> them out of a language, I find one more reason not to do so. Plus, 
> if you accept that the language should handle arbitrarily deep 
> recursion, you have all the implementation concepts worked out 
> anyway (mostly) so adding continuations to the language costs very 
> little. 

They are what makes Scheme different from other languages.  They're the 
reason that I am picking Scheme (likely typed Scheme initially) instead 
of OCaml for ths project.

So please don't get rid of them

-- hendrik

Posted on the users mailing list.