[racket] Generics and modules
J. Ian Johnson writes:
> You'll want foo-bar-baz the field accessor to be bound to something
> else that won't be shadowed when you define foo-bar-baz the generic
> function. Your define-generics likely is not in the same scope as
> the struct foo-bar definition, since
Right.
> Leads to a syntax error that there is a duplicate definition of
> x. Since #:methods reintroduces the names from bar's definition
> context into the following [...] scope, you're hosed for using the
> name. However, you can use unsafe-struct-ref
That's an interesting option. I am not very fond of having the word
"unsafe" in my code, but it does get the job done.
Neil Van Dyke writes:
> BTW, I've found that the generated struct accessor names very often
> conflict with names of procedures and of other structs. (Latest
Me too.
> I'm recently trying a convention of naming structs (except for exception
> structs) with a "-struct" suffix (e.g., "roomba-struct",
> "roomba-protocol-struct"), and then doing "(provide (rename-out ...)
Good idea, I'll try it out on my code.
> I've been wondering whether it would be more practical for
> struct-generated names to concatenate with colon (":") as a separator,
> rather than with minus ("-").
My first idea would be a dot (used in many other languages), or a slash
(like in Unix path names, and also in Racket module names).
Konrad.