MathGroup Archive 2007

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

Search the Archive

Re: private routines in mathematica 6 packages?


Tanim Islam wrote:

> How do I make certain functions within a mathematica package private or
> protected? By private or protected, I mean that these functions cannot be
> called directly by the user in a mathematica notebook.

Enclose all your function within a private block (f and g in the example 
below). Write a usage message for the functions that must be exported (f 
in our case), everything else will be hidden (that is g in the toy example).

-------------------------- beginning of the file -----------------------

BeginPackage["mypackage`"]

f::usage = "f[x] returns the square of the sin of x."

Begin["`Private`"]

g[x_] := Sin[x]

f[x_] := g[x]^2

End[ ]

EndPackage[ ]

----------------------------- end of the file --------------------------

-- 
Jean-Marc


  • Prev by Date: Re: a simple question about contour3D
  • Next by Date: Re: Plotting a straight line in a 3D plot
  • Previous by thread: Re: private routines in mathematica 6 packages?
  • Next by thread: [Mathematica 6.0.1] Confusing documentation on ColorData, where to get list of ColorFunctions ?