[racket] Generics and modules

From: Greg Hendershott (greghendershott at gmail.com)
Date: Tue Aug 27 14:03:43 EDT 2013

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

1. Yes. In addition to name conflicts, it's harder on human code
readers (or at least, me) when '-' is overloaded. Especially if the
struct name and/or field name have a hyphen. Quick, is 'a-b-c' a
struct 'a' with a field 'b-c', or a struct 'a-b' with a 'c' field?
Using ':' would be clearer. (If '.' weren't a special reader char,
that would be even better, wrt other langs.)  It's not a huge deal,
but it's a bit more cognitive load when learning Racket and even (for
me) reading code after a few years.

2. Also, although I haven't given it deep thought and maybe it's a
poor idea, I'd like structs to join the `dict` club to which almost
everything else belongs.

That way, if `r` were an instance of a `roomba` struct with a
`protocol` field, you could say something like

    (dict-ref r 'protocol)

And further, if you're willing to pay more runtime cost of redefining
#%app, you could also sugar as:

  (r 'protocol)


  ('protocol r)

Plus a threading macro can make nested struct references nearly as
concise as in a {} lang.

Maybe this is a silly idea because, if I _really_ want this, today I
could simply choose some dict such as a hasheq instead of using a
struct. Well, for my own data definitions; there's still the matter of
working with other collects.

Posted on the users mailing list.