Kevin,

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

On Tue, Mar 3, 2020 at 11:08 AM Kevin Forchione <lyss...@gmail.com> 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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxzv7S4gnxjZEDT7yD%3Dm8Y4R6t4fCFjFKyixR99r%2Bc15qQ%40mail.gmail.com.

Reply via email to