diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-27 11:48:10 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-27 11:48:10 -0800 |
commit | 1f54a294cb92edc7be1b11953244947d8108456a (patch) | |
tree | 6c578c82a035e8d7f88772899dca376ff8dfb627 | |
parent | 02cc74a75b774dfbe5ea4b4080b7d199bb30d6ca (diff) | |
download | txr-1f54a294cb92edc7be1b11953244947d8108456a.tar.gz txr-1f54a294cb92edc7be1b11953244947d8108456a.tar.bz2 txr-1f54a294cb92edc7be1b11953244947d8108456a.zip |
doc: update package example.
* txr.1: The example illustrating a module with
private and public symbols is altered to show a
superior practice: use a no-fallback package for
the public symbols, and be in the private package
when defining the module.
-rw-r--r-- | txr.1 | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -39712,34 +39712,34 @@ in a private package. .cblk ;; Define three packages. - (defpackage mod-priv) + (defpackage mod-priv + (:fallback usr)) - (defpackage mod - (:fallback mod-priv usr)) + (defpackage mod) (defpackage client (:fallback mod usr) (:use-from mod-priv other-priv)) - ;; Switch to mod package - (in-package mod) + ;; Switch to mod-priv package + (in-package mod-priv) - ;; Note that we don't have to change to the mod-priv package, - ;; to define functions with names in that package. - ;; We rely on interning being allowed for the qualified - ;; mod-priv:priv-fun syntax, which is permitted because - ;; mod-priv has no fallback list. This is useful precisely - ;; for this type of package. - (defun mod-priv:priv-fun (arg) + (defun priv-fun (arg) (list arg)) ;; Another function with a name in the mod-priv package. - (defun mod-priv:other-priv (arg) + (defun other-priv (arg) (cons arg arg)) - ;; This is mod:public-fun - (defun public-fun (arg) - (priv-fun arg)) + ;; Define a function in mod; a public function. + ;; Note that we don't have to change to the mod package, + ;; to define functions with names in that package. + ;; We rely on interning being allowed for the qualified + ;; mod:priv-fun syntax, which is permitted because + ;; mod has no fallback list. This is useful precisely + ;; for this type of package. + (defun mod:public-fun (arg) + (priv-fun arg)) ;; priv-fun here is mod-priv:priv-fun ;; Switch to client package (in-package client) |