From 79fdb76499cfa0c1bdf400f29a9e05dd8267118f Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 25 Jun 2017 14:11:44 -0700 Subject: [PATCH] ex --- .../restructure/generic-interface-example.rkt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pitfall/restructure/generic-interface-example.rkt diff --git a/pitfall/restructure/generic-interface-example.rkt b/pitfall/restructure/generic-interface-example.rkt new file mode 100644 index 00000000..fa42e38a --- /dev/null +++ b/pitfall/restructure/generic-interface-example.rkt @@ -0,0 +1,20 @@ +#lang br +(require data/collection racket/private/generic-methods) + +(define countable<%> + (interface* () + ([(generic-property gen:countable) + (generic-method-table gen:countable + (define (length o) + (send o length)))]))) + + +(define c (class* object% (countable<%>) + (super-new) + (define/public (length) 42))) + +c + +(define o (make-object c)) + +(length o) \ No newline at end of file