diff --git a/remix/class0.rkt b/remix/class0.rkt index 2d19dbc..1f6ed35 100644 --- a/remix/class0.rkt +++ b/remix/class0.rkt @@ -106,15 +106,16 @@ ([cls cls-id] [rep rep-id] [cls-vtables (format-id #f "~a-vtables" #'cls)] + [cls-this (format-id #f "~a-this" #'cls)] [cls-new (format-id #f "~a-new" #'cls)] [cls-Current (format-id #f "~a-Current" #'cls)] [cls-alloc* (format-id #f "~a-alloc*" #'cls)] [cls-alloc (format-id #f "~a-alloc" #'cls)] [((int int-vtable cls-int-impl cls-int-impl-def) ...) (for/list ([(int int-internal) (in-dict interface-set)]) - (define cls-int-impl (format-id #f "~a-~a" #'cls int)) + (define cls-int-impl-id (format-id #f "~a-~a" #'cls int)) (match-define (list int-vtable-id cls-int-impl-def) - (int-internal cls-int-impl)) + (int-internal cls-int-impl-id #'cls-this)) (list int int-vtable-id cls-int-impl cls-int-impl-def))] [cls-new-def (new-found? #'cls-new)]) (syntax/loc stx @@ -132,7 +133,7 @@ ([Current (make-rename-transformer #'cls-Current)]) cls-new-def cls-int-impl-def ... - ;; XXX bind cls-this + (remix:def (remix:#%brackets static-interface cls-this)) (remix:def (remix:#%brackets static-interface cls) (remix:#%brackets #:new cls-new) (remix:#%brackets int cls-int-impl) @@ -199,7 +200,7 @@ (with-syntax ([int-vtable-id (interface-vtable-id (attribute int.value))] [int-vtable (interface-vtable (attribute int.value))]) (dict-set! is #'int - (λ (cls-impl-id) + (λ (cls-impl-id cls-this-id) (list #'int-vtable-id (with-syntax ([cls-impl cls-impl-id]) diff --git a/remix/static-interface0.rkt b/remix/static-interface0.rkt index cffe90d..1fe1135 100644 --- a/remix/static-interface0.rkt +++ b/remix/static-interface0.rkt @@ -202,6 +202,4 @@ static-interface? static-interface-members)) - - ;; xxx data (fixed set of interfaces) diff --git a/remix/tests/class.rkt b/remix/tests/class.rkt index 63ffac4..ad4e5e6 100644 --- a/remix/tests/class.rkt +++ b/remix/tests/class.rkt @@ -31,20 +31,16 @@ (impl 2d<%> [translate (λ (x y) - {this.#:set + (this.#:set [c (this.c.#:set [x {x + this.c.x}] - [y {y + this.c.y}])]})] + [y {y + this.c.y}])]))] [area (λ () {3 * this.r * this.r})])) ;; XXX allow w/o #:new?, like layout -;; XXX -#; -(def [Circle C1] (Circle.#:new 1 2 3)) -;; XXX -#; (module+ test + (def [Circle C1] (Circle.#:new 1 2 3)) ;; If you know something is a particular class, then you can access ;; its implementations directly. This is more efficient. {C1.Circle<%>.c.x ≡ 1} @@ -64,8 +60,6 @@ {C1-as-Circ.c.y ≡ 2} {C1-as-Circ.r ≡ 3}) -;; XXX -#; (module+ test ;; Like theories, you can define functions that are generic over an ;; interface.