Tag Info

Hot answers tagged

11

In your situation, the standard approach is usually different. This means, I use something like this only BeginPackage["PQR`" ,{"PQR`PQRVisualization`","PQR`PQRUtilities`"}] when I need the functionality of the Visualization and Utilities inside my package, not to re-export them. What about creating an directory structure the following way PQR ├── Kernel ...


7

After running your Package code the first time Test1` is added to the $ContextPath. When you call Test1`function1[5] the symbol function1 is created in the context Test1` After calling BeginPackage["Test1`"] and Begin["`Private`"] the $ContextPath is: {"Test1`","System`"} When you use function1 in function1[x_] := x it is found in the $ContextPath and ...


7

The following should make it pretty difficult to use function1 elsewhere: BeginPackage["Test1`"]; f2::usage = "f2 usage message"; Begin["`" <> StringJoin @@ RandomChoice[CharacterRange["a", "z"], 30] <> "`"]; function1[x_] := x; f2[x_] := 2 function1[x]; SetAttributes[f2, {Protected, ReadProtected, Locked}]; End[]; EndPackage[]; The trick is ...


5

It looks like FeynArts did not get patched. Please follow the instructions here, i.e., reinstall fc820.zip and then do : $LoadPhi=True; Needs["HighEnergyPhysics`FeynCalc`"]; If I find time I update FeynCalc to include a patched FeynArts. The problem is that some examples in fcexamples do not work with FeynArts 3.7 and I need to have a look at how to fix ...


2

If you insist to write code this way I think you should really try to understand what $ContextPath and $Context do and how BeginPackage,EndPackage, Begin and End control these. As Mr. Wizard has explained the problem you are facing is that within the private part of the package Test1` is in $ContextPath, but not Test1`Private`. If neither Test1`function1 ...


2

Mathematica does not automatically search the directory containing the current notebook. You can verify this with $Path. As noted by bill s in comments, you can specify full paths to the files (in quotes). Alternatively, you can use the following: SetDirectory[NotebookDirectory[]]


1

You could make your function an inline function. BeginPackage["Test1`"]; (*this is a function with several invocations, which we'd like to inline*) function2[x_Integer] := 2 + 1 function2[x_Symbol] := x ReleaseHold[ Hold[ (*Non-private definitions go here*) privateCaller[y_] := (Print["This is some functionality."]; ...


1

You could try this: BeginPackage["Test1`"]; ClearAll[function1]; function1::usage = "test"; Begin["`Private`"]; function1[x_] := x End[]; EndPackage[]; Using Test1`Private`function1 is despising the whole idea of using a package in the first place. There is more information in tutorial/SettingUpMathematicaPackages (You can put this in the help browser.)



Only top voted, non community-wiki answers of a minimum length are eligible