diff options
-rw-r--r-- | modules/language/python/persist.scm | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/modules/language/python/persist.scm b/modules/language/python/persist.scm index 1835201..dc1e409 100644 --- a/modules/language/python/persist.scm +++ b/modules/language/python/persist.scm @@ -16,10 +16,10 @@ (vhash-fold (lambda (k v s) (if (hash-ref t k) - s - (begin - (hash-set! t k #t) - (cons (cons k v) s)))) + s + (begin + (hash-set! t k #t) + (cons (cons k v) s)))) '() v))) (define-method (pcopyable? (o <p>)) #t) @@ -27,24 +27,24 @@ (define (cp o) (match (red o) - ((#:reduce mk f) - (let ((oo (mk))) - (for-each (lambda (x) (apply (car x) oo (cdr x))) f) - oo)))) + ((#:reduce mk f) + (let ((oo (mk))) + (for-each (lambda (x) (apply (car x) oo (cdr x))) f) + oo)))) (define (red o) (fluid-set! first #t) (list #:reduce - (let ((cl (class-of o))) - (lambda () (make cl))) - (reduce o))) + (let ((cl (class-of o))) + (lambda () (make cl))) + (reduce o))) (define-method (pcopy (o <p>)) (list #:obj - (aif it (ref o '__copy__) - (it) - (cp o)))) + (aif it (ref o '__copy__) + (it) + (cp o)))) (define-method (deep-pcopy (o <p>) p?) (aif it (and p? (ref o '__deepcopy__)) @@ -56,23 +56,23 @@ (define-method (reduce (o <p>)) (if (fluid-ref first) (begin - (fluid-set! first #f) - (cons - (aif it (ref o '__reduce__) - (it) - (cons - (lambda (o args) - (let ((h (make-hash-table))) - (slot-set! o 'h h) - (for-each - (lambda (x) (hash-set! h (car x) (cdr x))) - args))) - (list - (hash-fold - (lambda (k v s) (cons (cons k v) s)) - '() - (slot-ref o 'h))))) - (next-method))) + (fluid-set! first #f) + (cons + (aif it (ref o '__reduce__) + (it) + (cons + (lambda (o args) + (let ((h (make-hash-table))) + (slot-set! o 'h h) + (for-each + (lambda (x) (hash-set! h (car x) (cdr x))) + args))) + (list + (hash-fold + (lambda (k v s) (cons (cons k v) s)) + '() + (slot-ref o 'h))))) + (next-method))) (next-method))) (define (fold f s l) @@ -83,20 +83,20 @@ (define-method (reduce (o <pf>)) (if (fluid-ref first) (begin - (fluid-set! first #f) - (cons* - (cons - (lambda (o n args) - (slot-set! o 'size n) - (slot-set! o 'n n) - (let ((h - (fold - (lambda (k v s) (vhash-assoc k v s)) - vlist-null - args))) - (slot-set! o 'h h))) - (list (slot-ref o 'n) (vhash->assoc (slot-ref o 'h)))) - (next-method))) + (fluid-set! first #f) + (cons* + (cons + (lambda (o n args) + (slot-set! o 'size n) + (slot-set! o 'n n) + (let ((h + (fold + (lambda (k v s) (vhash-assoc k v s)) + vlist-null + args))) + (slot-set! o 'h h))) + (list (slot-ref o 'n) (vhash->assoc (slot-ref o 'h)))) + (next-method))) (next-method))) (define-syntax cpit @@ -104,11 +104,11 @@ (syntax-case x () ((_ <c> (o lam a)) #'(begin - (define-method (pcopyable? (o <c>) ) #t) - (define-method (deep-pcopyable? (o <c>) ) #t) - (define-method (pcopy (o <c>) ) (cp o)) - (define-method (deep-pcopy (o <c>) p?) (red o)) - (define-method (reduce (o <c>) ) - (cons* - (cons lam a) - (next-method)))))))) + (define-method (pcopyable? (o <c>) ) #t) + (define-method (deep-pcopyable? (o <c>) ) #t) + (define-method (pcopy (o <c>) ) (cp o)) + (define-method (deep-pcopy (o <c>) p?) (red o)) + (define-method (reduce (o <c>) ) + (cons* + (cons lam a) + (next-method)))))))) |