Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a Mathematica packagr and then I used the Needs function to add the library to my .nb file, but when use a function in my .nb file and the function is built in my library it comes up with the functions output multiplied by "mylibrarynamePrivate".

My Package:

Unprotect @@ Names["Afak10`*"]; 
ClearAll @@ Names["Afak10`*"]; 
f::usage = "f[x]" 
f[x_] := Module[{}, x^2 + s]; 
Protect @@ Names["Afak10`*"]; 


Afak10`Private`s + x^2

What if I define f[x] as:

f[x_] := Module[{asdfs},asdfs];

The Output is:

share|improve this question
You need to give a more concrete example of your functions and how you are using them. I can think of a few different possible causes for this but I don't feel like explaining problems that don't exist. – Mr.Wizard Jan 25 '14 at 9:34
Well its a big package with many functions, some of them are fine and others aren't – user38032 Jan 25 '14 at 16:02
If you want help, then find a simple case: make up a small package that has the same problem. Then we can try and help. – bill s Jan 25 '14 at 16:21
Take this library for example: – user38032 Jan 25 '14 at 22:00
BeginPackage["Afak10"] Unprotect @@ Names["Afak10*"]; ClearAll @@ Names["Afak10*"]; f::usage = "f[x]" Begin["Private"] f[x_] := Module[{}, x^2 + s]; End[] Protect @@ Names["Afak10*"]; EndPackage[] – user38032 Jan 25 '14 at 22:01

In your code you have a Symbol s that is not declared before the line Begin line. Because of this it is created in that specified Afak10`Private` context. (Also, your code presently has an error; it needs to be Begin["Private`"].) You can include the Global` context if that is in fact the Symbol you wish to return:

f[x_] := Module[{}, x^2 + Global`s];  (* as part of your package *)

Now using the function:

s + z^2

Nevertheless I caution you about this method as you generally should not use (plain) global Symbols like this; instead use Formal Symbols which are Protected to prevent accidental assignment.

f[x_] := Module[{}, x^2 + \[FormalS]];

It looks like this:

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.