Re: [racket-users] [racket users] Generics question

2020-03-03 Thread Kevin Forchione
> On Mar 3, 2020, at 10:48 AM, Jon Zeppieri wrote: > > On Tue, Mar 3, 2020 at 12:37 PM Kevin Forchione wrote: >> >> Thanks! That brings me a little closer in appreciating the comments I’ve >> read about replacing object-oriented code with structs and methods. >> >> Is this part of the

Re: [racket-users] [racket users] Generics question

2020-03-03 Thread Jon Zeppieri
On Tue, Mar 3, 2020 at 12:37 PM Kevin Forchione wrote: > > Thanks! That brings me a little closer in appreciating the comments I’ve > read about replacing object-oriented code with structs and methods. > > Is this part of the racket/generic or the Multimethods library? The example > you

Re: [racket-users] [racket users] Generics question

2020-03-03 Thread Kevin Forchione
> On Mar 3, 2020, at 9:19 AM, Jon Zeppieri wrote: > > (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]) Thanks! That

Re: [racket-users] [racket users] Generics question

2020-03-03 Thread Jon Zeppieri
Kevin, 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

[racket-users] [racket users] Generics question

2020-03-03 Thread Kevin Forchione
Hi guys, If I create a generic, say foo, for a particular struct and then later reference that method on a different type of struct from within the handler method I get an error because the call goes to the original structs method and not to the method of the other struct. Is there a way to do