net@opal.cs.tu-berlin.de (Oliver Laumann) (05/31/91)
In article <9105302308.AA18221@cymbal.reasoning.com.> Gyro@reasoning.com writes: > I'm trying to map the various C control statements into > Scheme. The translation of break, continue, and return > are giving me trouble. [..] > > I suspect I need to do something with call-with-current-continuation > > 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; e.g. I suppose what the original poster wanted is to be able to write (return expression) in the middle of a function body to terminate the function and return the value of an expression. If Scheme had macros, this could be implemented easily by defining a new version of `define' that wraps a call/cc around the body of the function: (define-macro (improved-define head . body) `(define ,head (call-with-current-continuation (lambda (return) ,@body)))) `improved-define' could then be used like this: (improved-define (redraw window) (if (invisible? window) (return #f)) ;; do something complex... ) -- Oliver Laumann net@tub.cs.tu-berlin.de net@tub.UUCP ol@gnu.ai.mit.edu