This page is part of the web mail archives of SRFI 18 from before July 7th, 2015. The new archives for SRFI 18 contain all messages, not just those from before July 7th, 2015.
Matthias Felleisen <matthias@xxxxxxxxxxx> writes: > May I ask a heretical question (especially from me): > > How many of you use call/cc and continuation objects > (rather than mimicing continuations with lambda's) > in large programs? Do "we" really use it to implement > coroutines and backtracking and threads and whatever? Well, my current project (which was intended to be a quick-and dirty hack and is taking over my life :) is a Scheme->Scheme compiler (motivated by the desire to have a nice source code partitioning system and SRFI support in Stalin). It is now pushing 3000+ lines of original code, with an Essence (thanks Mr. Preprocessor) parser and bits of SLIB tacked on for good measure. I'm using call/cc for four times internally. Once is to create a global exception handling environment. Another is to decompose the loop that grovels over source forms checking for all the different source partitioning systems out there (I've got Bigloo, Guile, and SLIB (w/variants) covered). One is to short-circuit the name collision detection loop (NB: this code doesn't work right). And one is to tame the parser (essentially co-routining it). Of these four uses, only the first is *necessary*, as there is no standard way to cause a Scheme program to terminate without returning from the main function [equiv. C exit()]. The second one allows me to modularize a big ugly loop, yet retain the (theoretical) efficiency of implementing it with local tail calls. I could easily code around the lack of call/cc, and it might even *really* be the right thing (TM). I'm pretty sure that the third one was just being too clever, and that there's a better way to do it. I'd have to do a major rewrite to get around the fourth (Co-routining the Essence parser). Call/cc was a major win for me there, as it let me continue to have my code structured like I was using Scheme's READ while using my own parser with all of the advantages that brings (for error location, case sensitivity etc...) > Is call/cc necessary for Scheme? I would miss it, yes. OTOH, it seems like it could be implemented entirely as a source transformation. In this opinion I may very well be displaying my ignorance of some of the deeper issues. On an informal level, it feels very 'global' in its effects. I do find it interesting that you introduced expression contexts (which were my first introduction to call/cc in _Scheme_and_the_Art_of_Programming_) as part of your explanation of the compatible closure for lambda expressions in your CS 411 monograph. I'd never thought of it as quite so fundamental operation before... david rush