How can I avoid to define public all methods in a package

0

If I have to code a Package and these package use a lot of functions and variables. In spite of, using in every call of function or variable with namePackage preffix. I've been used usageshortcut for each one of them. But, it makes public for every one of these variables. My question is: there are another way to avoid the prefix(because it is ugly, I think so) and still have methods and variables for private?

(* my style *)
BeginPackage["Test`"];
f::usage = "";
(* the following is public, but I don't want to. Nevertheless.
I exposed them, because I don't want to be writing the prefix for the package.*)
var1::usage = ""; 
var2::usage = "";

g::usage = "";
Begin["`Private`"];


f[]:=Module[{},
  var1 = 2;
  var2 = 4;
  g[var1, var2];
];

g[a_,b_]:=2;
End[]

EndPackage[];

jonaprieto

Posted 2015-05-29T07:09:43.063

Reputation: 1 017

Question was closed 2015-05-29T08:14:46.673

If you want var1, var2, and g to be private, just don't put in usage messages for them! Long as you're in the private context (due to Begin[]), they're usable without the need to declare their full context. – J. M.'s ennui – 2015-05-29T07:28:57.060

you only make usage:: for functions that are to be called from outside. Not for all the variables. It is similar to Java class or C++ class, where you make public functions. – Nasser – 2015-05-29T07:29:11.870

No answers