This question already has an answer here:
I've been working on a Mathematica package (call it
QuantumDot) that has become huge. Right now, all the back-end helper functions are in context
QuantumDot`Private, and the WHOLE code is in one gigantic .m file.
I'd like to reorganize it so that
QuantumDot has multiple sub-contexts corresponding, roughly, to each front-end function. I want to put all the back-end helper functions into these sub-contexts.
(*These are the main functions accessible to the user*) QuantumDot` MainFunction[x,y,z] ComplexRoutine[x,y] (*These are the backend helper functions*) QuantumDot`MainFunction` internalFunction[a,b,c] addAndSubtract[a,b,c] distribute[a,b,c] ... QuantumDot`ComplexRoutine` step1function[a,b,c] step2function[a,b,c] reducer[a,b,c] ...
I can achieve this by replacing in my existing code
Begin["`ComplexRoutine `"],... as necessary.
BeginPackage["QuantumDot`"]; MainFunction::usage = "MainFunction[x,y,z] is a front-end function for users"; Begin["`MainFunction`"]; (* was Begin["`Private`"]; *) internalFunction[a_,b_,c_] := a^2 - b^2 - c^2; addAndSubtract[a_,b_,c_] := a + b - c; distribute[a,b,c] := a(b+c)//Expand; MainFunction[x_,y_,z_]:=internalFunction[x,y,z]+addAndSubtract[x,y,z](*...*); End; Begin["`ComplexRoutine`"]; (*...*) End; EndPackage;
The problem is that the autocomplete picks up the back-end functions. (Apparently, there was something special with the "Private" context).
What can I do to prevent the autocompletion feature from displaying these internal functions?
I then intend to split my package into multiple
.mfiles according to the main functions of the package. Is this a reasonable way to proceed?