Hi,
dmitry grebeniuk < gds-mlsts%40moldavcable.com">gds-mlsts
moldavcable.com> writes:
Have no idea about your efficiency problem, but recursive module seems like a
heavy-weight solution for me. I will only take this approach if there is some
reason making it considerably elegant than other solutions.
>
> type my_struct =
> { ...
> ; current_state : mutable state_t
> }
> and state_t =
> { ... some references to my_struct ... }
> }
> ;
>
> Everything looks good, but I want to create and modify
> values of type state_t only inside one small module.
> Can this be done using something like "private"?
> (type state_t is represented by record).
Yes, this is exactly the private type. Prefix the "private" keyword to the
definition of state_t in the signature will do it.
type my_struct = { ... } and state_t = private { ... }
It means, you can still access the elements in values of state_t type as
normal (with the dot notation), but won't be able to create such value
directly (unless through primitive function provided by this module) or update
its elements from outside (even if they are mutable).
.