guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I can't seem to get throw/catch to work


From: Peter S. Christopher
Subject: Re: I can't seem to get throw/catch to work
Date: Wed, 30 Jul 2003 09:45:11 -0500 (CDT)

Hi there,

        The second argument to catch must be a thunk (zero
argument procedure). So your first example should be

(catch #t 
        (lambda () (throw 'foo))
        (lambda (key . args) (display key) (newline)))

The way you had it written, the (throw 'foo) was being evaluated before
the catch was fully established.

cheers, 
Pete

On Wed, 30 Jul 2003, Tim Brown wrote:

> I'm just starting to get up and running with guile (and scheme).
> 
> I'm trying to write a C extension which (eventually) will throw an
> exception/error back to guile. I cannot catch an error generated with
> scm_throw(). More importantly I can't seem to throw and error within
> guile and catch it myself.
> 
> guile> (catch #t (throw 'foo) (lambda (key . args) (display key) (newline)))
> <unnamed port>:1:11: In procedure gsubr-apply in expression (throw 
> (quote foo)):
> <unnamed port>:1:11: unhandled-exception: foo
> ABORT: (misc-error)
> 
> Type "(backtrace)" to get more information or "(debug)" to enter the 
> debugger.
> guile>
> 
> Ok, so that's me throwing my own error to myself. But I can't even catch
> an exception generated by guile.
> 
> Neither generally, using the (catch #t ...) nor specifically, using
> (catch 'numerical-overflow ...):
> 
> guile> (catch #t (/ 1 0) (lambda (key . args) (display key) (newline)))
> <unnamed port>:2:11: In procedure / in expression (/ 1 0):
> <unnamed port>:2:11: Numerical overflow
> ABORT: (numerical-overflow)
> guile> (catch 'numerical-overflow (/ 1 0) (lambda (key . args) (display 
> key) (newline)))
> <unnamed port>:3:28: In procedure / in expression (/ 1 0):
> <unnamed port>:3:28: Numerical overflow
> ABORT: (numerical-overflow)
> guile> (version)
> "1.6.4"
> 
> This happens on linux, solaris and hpux builds, so I assume there's a
> problem with my use of the language rather than anything else.
> 
> What am I missing here?
> 
> Tim
> 
> -- 
> Tim Brown <address@hidden> |            City Computing Limited |
> T: +44 20 8770 2110               |      City House, Sutton Park Road |
> F: +44 20 8770 2130               |       Sutton, Surrey, SM1 2AE, GB |
> BEAUTY: What's in your eye when you have a bee in your hand.__________/
> 
> 
> 
> 
> 
> _______________________________________________
> Guile-user mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/guile-user
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]