[racket] method implementation after struct

From: Alexander D. Knauth (alexander at knauth.org)
Date: Fri Feb 6 22:22:22 EST 2015

Well, you can do something like this:
#lang racket
(struct thing (name) #:transparent
  #:methods gen:custom-write
  [(define (write-proc thing out mode) (implementation thing out mode))])
stuff …
(define (implementation thing out mode)
  (display (thing-name thing) out))

On Feb 6, 2015, at 10:13 PM, Anthony Carrico <acarrico at memebeam.org> wrote:

> It seems like the implementation of a generic method must come before
> the structure definition:
> 
> (struct Protocol (name interfaces)
>        #:transparent
>        #:methods gen:dumpable
>        ((define dump dump-Protocol)))
> 
> (define (dump-Protocol p out) ...)
> 
> ; dump-Protocol: undefined;
> ;  cannot reference an identifier before its definition
> 
> Is this a bug? Just a limitation?
> 
> -- 
> Anthony Carrico
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.