applicable structs used
[software/python-on-guile.git] / modules / language / python / exceptions.scm
1 (define-module (language python exceptions)
2 #:use-module (oop pf-objects)
3 #:use-module (oop goops)
4 #:export (StopIteration GeneratorExit RuntimeError
5 Exception))
6
7 (define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
8
9 (define StopIteration 'StopIteration)
10 (define GeneratorExit 'GeneratorExit)
11 (define RuntimeError 'RuntimeError)
12
13 (define-python-class Exception ()
14 (define __init__
15 (case-lambda
16 ((self)
17 (values))
18 ((self str)
19 (set self 'str str))))
20
21 (define __repr__
22 (lambda (self)
23 (aif it (ref self 'str #f)
24 (format #f "~a:~a"
25 (ref self '__name__) it)
26 (format #f "~a"
27 (ref self '__name__))))))
28
29
30
31
32