diff options
author | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2017-10-01 23:28:06 +0200 |
---|---|---|
committer | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2017-10-01 23:28:06 +0200 |
commit | 272b703fd65335a7cb3c745eab91417b4a897907 (patch) | |
tree | 0d4e7964101fe7c6a50ab2efc28b6bd53dc09e81 /modules/oop/pf-objects.scm | |
parent | 0c1d43a631486f00ea26cb6eaa685509caf77d50 (diff) |
more pythonic number system
Diffstat (limited to 'modules/oop/pf-objects.scm')
-rw-r--r-- | modules/oop/pf-objects.scm | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/modules/oop/pf-objects.scm b/modules/oop/pf-objects.scm index 62c522b..5937d37 100644 --- a/modules/oop/pf-objects.scm +++ b/modules/oop/pf-objects.scm @@ -398,51 +398,6 @@ explicitly tell it to not update etc. x))) ;; this shows how we can override addition in a pythonic way -(define-syntax-rule (mk-arith + +x __add__ __radd__) - (begin - (define-method (+ (x <p>) y) - (call x '__add__ y)) - - (define-method (+ x (y <p>)) - (call y '__radd__ x)) - - (define-method (+ (x <py>) y) - (let ((f (mref-py- x '__add__ '()))) - (if f - (f y) - (+x y x)))) - - (define-method (+ (x <pyf>) y) - (let ((f (mref-py x '__add__ '()))) - (if f - (let ((res (f y))) - (if (eq? res not-implemented) - (+x y x) - res)) - (+x y x)))) - - (define-method (+ (x <py>) y) - (let ((f (mref-py- x '__add__ '()))) - (if f - (let ((res (f y))) - (if (eq? res not-implemented) - (+x y x) - res)) - (+x y x)))) - - (define-method (+ x (y <py>)) - (call y '__radd__ x)) - - (define-method (+ x (y <pyf>)) - (call y '__radd__ x)) - - (define-method (+x (x <p>) y) - (call x '__radd__ y)))) - -;; A few arithmetic operations at service -(mk-arith + +x __add__ __radd__) -(mk-arith - -x __sub__ __rsub__) -(mk-arith * *x __mul__ __rmul__) ;; lets define get put pcall etc so that we can refer to an object like ;; e.g. (put x.y.z 1) (pcall x.y 1) |