[racket] naming structs that are members of other structs
Whenever I encounter this situation, I tend to switch to Racket's class system:
(define vehicle
(class object%
(define vehicle-state
(class object%
(field position ;; 3D point
velocity ;; real
)
...))
(field state ;; vehicle-state
color ;; color-string
model ;; six-digit integer
)
(define/public ...)))
This arrangement expresses the close association between vehicles and their state.
If you wish to stay purely functional, the above is workable but it poses a few small obstacales.
On Feb 13, 2013, at 3:38 PM, Dmitry Pavlov wrote:
> Danny, I would not treat this problem as similar to
> the helper() function name conflict you mentioned.
> Having two structures referring to each other
> in the same module is a much lesser sin than
> having two equally named things in the same module.
>
> So I would prefer to solve this with a proper naming
> convention within a module, rather than putting each
> struct inside its own module.
>
>
> Stephen, thanks for the tip about the #:constructor-name.
> I think I may use that. Another solution, which just
> came to my head, is naming the structure
> vehicle/state instead of vehicle-state.
>
> Best regards,
>
> Dmitry
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users