Adding more explanation on using provide.

svn: r11275
This commit is contained in:
Danny Yoo 2008-08-15 18:49:25 +00:00
parent 72915b1bbd
commit 2d7ace4a19

View File

@ -755,10 +755,8 @@ model. There's one additional expression that looks a little odd at first:
] ]
which tells PLT Scheme to allow other files to have access to which tells PLT Scheme to allow other files to have access to
everything that's defined in the @filepath{model.ss} file. There are everything that's defined in the @filepath{model.ss} file.
situations where we may want to hide things for the sake of s private
functions, or the internal representation of structures, in which case
the pro
We change our web application to use this model. Going back to our We change our web application to use this model. Going back to our
web application, we rip out the old model code, and replace it with an web application, we rip out the old model code, and replace it with an
@ -873,7 +871,27 @@ post structure, rather the structure itself, to better abstract the model interf
@bold{Exercise.} Write the new definitions of @scheme[blog-insert-post!] and @scheme[post-insert-comment!]. @bold{Exercise.} Write the new definitions of @scheme[blog-insert-post!] and @scheme[post-insert-comment!].
(Remember to call @scheme[save-blog!].) (Remember to call @scheme[save-blog!].)
We'll change the @scheme[provide] line in the model to:
In our last iteration of our model, we used @scheme[(provide
(all-defined-out))] to expose all of the model's definitions. But we
often want to hide things like private functions and internal data
structures from others. We'll do that here by using a form of
@scheme[provide] that explicitly names the exposed definitions.
For example, if we wanted to limit the exposed functions to
@scheme[blog-insert-post!] and @scheme[post-insert-comment!], we can
do this:
@schemeblock[
(provide blog-insert-post!
post-insert-comment!)
]
Of course, this set of functions is too minimal! Let's change the
@scheme[provide] line in the model to:
@schemeblock[ @schemeblock[
(provide blog? blog-posts (provide blog? blog-posts
post? post-title post-body post-comments post? post-title post-body post-comments