MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mma Package Style Question

  • To: mathgroup at
  • Subject: [mg8474] Re: [mg8399] Mma Package Style Question
  • From: Allan Hayes <hay at>
  • Date: Tue, 2 Sep 1997 16:15:11 -0400
  • Sender: owner-wri-mathgroup at

"Xah" <xah at>
in [mg8399] Mma Package Style Question

Normaly, the usage message for exported functions are placed between
BeginPackage["xxx`"] and Begin["`Private"], but I like to place my  
functiondefinitions and usage message together in the Private  
section of the package, for easy development and maintenance.

My question is, are there ANY foreseeable reason not to do this? I'd
appreciate any help from wri fellow. Thanks. (below is an example  
of how my package might look like)



fff::usage="fff blurs your memory";
fff::err="You've erred in this and that way."

fff[_]:=Print["Your memory is now blured."];

ggg::usage="ggg[] gives you a hynosis."

ggg[_]=Print["Your memory was blurred."];


End[ ]

Protect[ fff,ggg,... ]

EndPackage[ ]

Your OK so long as you first introduce the symbols to be exported  
between BeginPackage[..] and Begin[.].
They will then be created in the Package context.
This you do with Clear[fff,ggg...]
Any symbol hh that is introduced first between Begin[.] and End[]  
will be created in the context "Private`blur" , its long name will  
be blur`Private`hh and and will not be accessible by its short name  

You might like to consider preceding Clear[..] with Unprotect[...]  
otherwise, on reloading, the protection given at the end will  
prevent clearing and give rise to messages.

The normal pattern protects one a little against forgetting to  
create exported symbols properly.
Incidentally, your positioning would not allow you to use one of my  
favourite tricks :  Unprotect["`*"], Unprotect["`*"] which  
automatically deal with all package context symbols -- unless you  
introduced all exported symbols some other way before Begin[].


Allan Hayes
hay at
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK

  • Prev by Date: Re: Flat: Problems & Workarounds
  • Next by Date: Re: ReadList and FortranForm data
  • Previous by thread: Re: Flat: Problems & Workarounds
  • Next by thread: Re: ReadList and FortranForm data