Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!sdd.hp.com!caen!uwm.edu!uwvax!daffy!saavik.cs.wisc.edu!quale From: quale@saavik.cs.wisc.edu (Douglas E. Quale) Newsgroups: comp.lang.scheme Subject: Re: C->Scheme mappings Message-ID: <1991May31.184707.22670@daffy.cs.wisc.edu> Date: 31 May 91 18:47:07 GMT References: <1991May28.191834.15025@apd.mentorg.com> <9105302308.AA18221@cymbal.reasoning.com.> <1991May31.093235.25653@news.cs.indiana.edu> Sender: news@daffy.cs.wisc.edu (The News) Organization: University of Wisconsin -- Madison Lines: 36 In article <1991May31.093235.25653@news.cs.indiana.edu> hieb@heston.cs.indiana.edu (Robert Hieb) writes: >gyro@cymbal.reasoning.COM (Scott Layson Burson) writes: > > >> Date: 28 May 91 19:18:34 GMT >> From: "Joe Mueller @ APD x1367" > >> I'm trying to map the various C control statements into >> Scheme. The translation of break, continue, and return >> are giving me trouble. > >>You don't need call-with-current-continuation. > >>`return' is implicit in Scheme: a lambda body always returns the value of its >>last form. So you don't have to do anything special with it... > >This is true only if the "return" is in tail position with respect to >the procedure body, which is not in general true in C code. Such code >can often be rewritten to put all return statements in tail position, >but that may not be the sort of transformation desired, and is not >always reasonable. To get a fully general return mechanism "call/cc" >IS required; one must wrap a call to "call/cc" around each procedure >body that has an explicit return in nontail position. One can then >invoke the continuation to return. > Actually regardless of where the return occurs, it is always possible to rewrite the code using no more than conditionals and procedure calls. A return is no more powerful than a goto, and gotos can be translated into procedure calls. The result isn't always very pretty. See the first published paper on lisp, by John McCarthy in CACM circa 1961.... (I've given up waiting for part 2!) -- Doug Quale quale@saavik.cs.wisc.edu