summaryrefslogtreecommitdiff
path: root/modules/language/python/dict.scm
diff options
context:
space:
mode:
authorStefan Israelsson Tampe <stefan.itampe@gmail.com>2017-10-05 00:56:12 +0200
committerStefan Israelsson Tampe <stefan.itampe@gmail.com>2017-10-05 00:56:12 +0200
commit16ff956cec889303fea7f8e235eba6876fb46c68 (patch)
tree8205e2dcff040d702ac77548ac4415891047444c /modules/language/python/dict.scm
parent5f8089beb5d77a186f4f00053edf45f1985bdb63 (diff)
super
Diffstat (limited to 'modules/language/python/dict.scm')
-rw-r--r--modules/language/python/dict.scm42
1 files changed, 25 insertions, 17 deletions
diff --git a/modules/language/python/dict.scm b/modules/language/python/dict.scm
index 5b6567b..f4d13a5 100644
--- a/modules/language/python/dict.scm
+++ b/modules/language/python/dict.scm
@@ -17,6 +17,8 @@
py-hash-ref dict pyhash-listing
))
+(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
+
(define (h x n) (modulo (py-hash x) n))
(define (py-hash-ref . l)
@@ -155,15 +157,19 @@
(define-method (nm (o class) l ...) code ...)
...
(define-method (nm (o <p>) l ...)
- ((ref o 'n) l ...))))
+ (aif it (ref o 'n)
+ (it l ...)
+ (next-method)))))
((_ (nm n o l ... . u) (class code ...) ...)
(begin
(define-method (nm (o class) l ... . u) code ...)
...
(define-method (nm (o <p>) l ... . u)
- (apply (ref o 'n) l ... u))))))
-
-
+ (aif it (ref o 'n)
+ (apply it l ... u)
+ (next-method)))))))
+
+
(define-py (py-copy copy o)
(<hashtable>
@@ -475,19 +481,21 @@
(define-python-class dict (<py-hashtable>)
(define __init__
- (case-lambda
- ((self)
- (let ((r (make-py-hashtable)))
- (slot-set! self 't (slot-ref r 't))
- (slot-set! self 'h (slot-ref r 'h))
- (slot-set! self 'n (slot-ref r 'n))))
- ((self x)
- (__init__ self)
- (if (is-a? x <py-hashtable>)
- (hash-for-each
- (lambda (k v)
- (pylist-set! self k v))
- (slot-ref x 't)))))))
+ (letrec ((__init__
+ (case-lambda
+ ((self)
+ (let ((r (make-py-hashtable)))
+ (slot-set! self 't (slot-ref r 't))
+ (slot-set! self 'h (slot-ref r 'h))
+ (slot-set! self 'n (slot-ref r 'n))))
+ ((self x)
+ (__init__ self)
+ (if (is-a? x <py-hashtable>)
+ (hash-for-each
+ (lambda (k v)
+ (pylist-set! self k v))
+ (slot-ref x 't)))))))
+ __init__)))
(define (pyhash-listing)
(let ((l (to-pylist