summaryrefslogtreecommitdiff
path: root/modules/language/python/bool.scm
blob: 3eb6bc865fa8da474b5619fdd87c90a004650ca2 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(define-module (language python bool)
  #:use-module (oop goops)
  #:use-module (oop pf-objects)
  #:export (bool))

(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))

(define-method (bool x)
  (cond
   ((null? x)
    #f)
   (else x)))

(define-method (bool (x <integer>)) (not (= x 0)))
(define-method (bool (x <p>))
  (aif it (ref x '__bool__)
       (it)
       (next-method)))