(define-module (language python tuple) #:use-module (oop goops) #:use-module (oop pf-objects) #:use-module (language python hash) #:use-module (language python for) #:export (tuple defpair)) (define-class () l) (define-method (py-hash (o )) (py-hash (slot-ref o 'l))) (define-method (py-class (o ) tuple)) (define-method (equal? (o1 ) o2) (equal? (slot-ref o1 'l) o2)) (define-method (equal? o1 (o2 )) (equal? o1 (slot-ref o2 'l))) (define-method (wrap-in (o )) (wrap-in (slot-ref o 'l))) (define-python-class tuple () (define __init__ (case-lambda ((self) (slot-set! self 'l '())) ((self it) (slot-set! self 'l (for ((x : it)) ((l '())) (cons x l) #:final (reverse l)))))) (define __repr__ (lambda (self) (format #f "~a" (slot-ref self 'l))))) (define-syntax-rule (defpair (f o . u) code ...) (begin (define-method (f (o ) . u) code ...) (define-method (f (o ) . u) (let ((o (slot-ref o 'l))) code ...))))