This is what `define/generic` is for. In your example:

On Tue, Mar 3, 2020 at 11:08 AM Kevin Forchione <> wrote:
> (struct A (this other) #:transparent
>   #:methods gen:foo
>   [(define (do-foo foo)
>      (printf "other=~a ~a"
>              (A-this foo)
>              (do-foo (A-other foo))))])

The call to `(doo-foo (A-other foo))` is simply a recursive call to
the function that you're in the middle of defining. In order to call
the generic method and have it dispatched appropriately, you need to
use `define/generic`:

(struct A (this other) #:transparent
  #:methods gen:foo
  [(define/generic generic-foo do-foo)
   (define (do-foo foo)
     (printf "other=~a ~a"
             (A-this foo)
             (generic-foo (A-other foo))))])

- Jon

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit

Reply via email to