[racket] Implementing an generic interface outside of a struct definition
Vincent St-Amour writes:
> You can use the `#:defaults' clause of `define-generics' for that. The
> documentation included in recent snapshots includes examples of its use:
>
> http://www.cs.utah.edu/plt/snapshots/current/doc/reference/struct-generics.html
>
> You can also use it to make basic datatypes (strings, numbers, etc.)
> implement a generic interface.
Great, thanks!
After some further thought, this doesn't really solve my problem since
the default definition needs to be part of the define-generics. The
case I am looking at is gen:dict, which is already defined elsewhere.
I do understand that implementing an already existing interface for an
already existing struct can pose a problem, since multiple library
modules could try to provide such an implementation and thus be in
conflict. But that's not really my situation either because I work on
my own structures. The reason for wanting to implement the methods
separately is plain economy: I have five structures that can use a
strictly identical implementation for gen:dict, and I want to write
the code only once.
So my real question is: is there a way to package method definitions
for reuse?
Konrad.