[plt-scheme] puzzled about multiple value return
GMTA I guess. That was very nice. Thank you both,
-pp
>
> You can use call-with-values, values, and apply:
>
> (define (helper thunk)
> (setup)
> (call-with-values thunk
> (lambda results
> (teardown)
> (apply values results))))
>
> Ryan
>
> > Here is my attempt:
> >
> > (define (helper thunk)
> > (let ((success #t))
> > (dynamic-wind
> > (lambda () (printf "Setup~n"))
> > (lambda ()
> > (with-handlers (((lambda ex #t)
> > (lambda (exn)
> > (set! success #f)
> > (raise exn))))
> > (thunk)))
> > (lambda()
> > (if success
> > (printf "Teardown~n"))))))
> >
> > > (helper (lambda () (values 1 2 3)))
> > Setup
> > Teardown
> > 1
> > 2
> > 3
> >
> > > (helper (lambda () 1))a
> > Setup
> > Teardown
> > 1
> >
> > > (helper (lambda () (error "Abort") (values 1 2 3)))
> > Setup
> > > Abort
> >
> > This seems to work, but its ugly. Is there a nicer solution?
> >
> > -pp
> >
> >
> >
> >
> > -pp
> > > _________________________________________________
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20060203/5427ad59/attachment.html>