[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I can't seem to get throw/catch to work
From: |
Dirk Eßer |
Subject: |
Re: I can't seem to get throw/catch to work |
Date: |
Wed, 30 Jul 2003 16:22:17 +0200 |
Tim Brown <address@hidden> schrieb am 30.07.03 13:25:12:
[ ... ]
> guile> (catch #t (throw 'foo) (lambda (key . args) (display key) (newline)))
> guile> (catch #t (/ 1 0) (lambda (key . args) (display key) (newline)))
AFAIK, catch is not a special form (as it is in CL), but a procedure, which
takes
procedures as arguments:
(catch THE-KEY-TO-CATCH BODY-THUNK HANDLER-THUNK)
where
BODY-THUNK is a procedure (lambda () ...), and
HANDLER-THUNK is something like (lambda (key . rest) ...)
So,
(catch #t (lambda () (throw ´foo)) (lambda (key . rest) ...))
(catch #t (lambda () (/ 1 0)) (lambda (key . rest) ...))
should actually do, what you expect.
The mistake in the original examples was, that due to catch being a procedure,
(throw ´foo) and (/ 1 0) are actually evaluated as part of the standard argument
evaluation process, which happens before the actual call; the catch-handler is
installed during execution of BODY-THUNK inside catch. But since evaluating
arguments
fails, catch itself is never actually called.
-- dirk
______________________________________________________________________________
Spam-Filter fuer alle - bester Spam-Schutz laut ComputerBild 15-03
WEB.DE FreeMail - Deutschlands beste E-Mail - http://s.web.de/?mc=021120