On 02/28/2012 10:22 PM, David T. Pierson wrote:
Hi all,
Many racket collections define some modules in a subdirectory named
"private". Presumably these modules are for definitions that are used
by other modules in the same collection but are not meant to be used
from outside the collection. As far as I can tell, this is just a
convention and is not enforced in any way. Are there any guidelines for
such "private" modules? I couldn't find anything searching the
documentation and the list archives.
As you say, it's a convention, but access control isn't enforced.
Guidelines: Avoid using other libraries' private modules. Don't
encourage other libraries to use your private modules (eg, put things
that need to be public in public modules). Try not to refer to private
module names in interface documentation, error messages, etc.
I'm considering such a private module to define a custom struct type.
The struct's fields would be used by multiple modules in my collection,
and instances of the struct would be used outside the collection, but I
want the struct to be opaque to code outside my collection. In other
words I'd reexport only the type predicate procedure from the main
module. Is this a typical use of "private" modules?
Yes, it's common to have a public module that selectively exports
bindings from one or more private modules. It's often a good idea to put
contracts on the public module's exports, although for simple predicates
it isn't that important.
Ryan
____________________
Racket Users list:
http://lists.racket-lang.org/users