[racket] generics + superstructs

From: Dmitry Pavlov (dpavlov at ipa.nw.ru)
Date: Wed Mar 13 12:39:01 EDT 2013


In short: I use inheritance of structures, I use structure generics,
but I can not combine inheritance and generics in the way that seems
the most natural.

#lang racket

(require racket/generic)

(define-generics my
   (some-base-stuff my)
   (some-specific-stuff my))

(struct base
   #:methods gen:my
   ((define (some-base-stuff my)
      (print (base-base-field my)))))

(struct specific base
   #:methods gen:my
   ((define (some-specific-stuff my)
      (print (specific-specific-field my)))))

(some-base-stuff (specific 2 4))

some-base-stuff: not implemented for #<specific>

Can generic #:methods be possibly inherited from superstructure?

Best regards,


Posted on the users mailing list.