Defining a private function in mathematica

I'm not sure that I managed to correctly define private functions. When I write a math package, I just do this:

BeginPackage["myPackage`"]
myPublicFunction::usage="myPublicFunction blahblahblah";
Begin["Private"]
myPrivateFunction[input_]:= ... ;
myPublicFunction[input_]:= ... ;
End[]
EndPackage[]

Is this right, or am I missing something?

+5
source share
1 answer

, . , . Mathematica . . . - "". , , , . . () $ContextPath. , , . , , , , ( ) $ContextPath, , . , . , - $ContextPath, .

, BeginPackage , , $ContextPath {youPublicPackageContext, "System'"} , , , BeginPackage. , "" , , "" , . EndPackage $ContextPath , . , - , myFunction; ( , , ). , Begin["'Private'"], , YourContext'Private' (). $ContextPath . , , ( $ContextPath), 'Private'.

, , , - (), $ContextPath, . , YourPackage'Private' $ContextPath (, PrependTo[$ContextPath, YourPackage'Private']), , . , , . , , , , $ContextPath $Context ( , ), , Begin BeginPackage. , BeginPackage, Begin, End EndPackage . , ( ), , , - , "" $ContextPath Context, , , "" . , , , , .

+12

All Articles