You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/restructure/generic-interface-example.rkt

20 lines
476 B
Racket

#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)