[racket] Generics and modules

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Tue Aug 27 12:50:56 EDT 2013

J. Ian Johnson wrote at 08/27/2013 12:18 PM:
> 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.

BTW, I've found that the generated struct accessor names very often 
conflict with names of procedures and of other structs.  (Latest 
example: structs "roomba" and "roomba-protocol", and struct "roomba" has 
a field named "protocol".  We could debate about how things should be 
composed and named in particular cases, but I think that name collisions 
are simply going to happen sometimes with current way of doing things.)

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 ...) 
...)" when I want to provide any of the struct-generated names.   So 
far, this convention has worked, because I usually provide only a small 
fraction of the struct-generated names, and treat it outside the 
defining module as an ADT rather than a struct.  (I also define write 
procedures for the structs, to maintain this facade, as well as to 
provide slick info.)

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 ("-").

Neil V.


Posted on the users mailing list.