3

I'm just going crazy with Mathematica Contexts as they absolute do not work as intended.

Simple Example:

Begin["TEST`"]
Hello[s_]:=s
Bye[s_]:=s
End[]

Now using TEST`Hello works:

TEST`Hello["test"]
test

The names of context TEST are:

Names["TEST`*"]
{"TEST`Bye", "TEST`Hello"}

Now I want to remove the Bye function as it is no longer needed:

Clear["TEST`Bye"]
Names["TEST`*"]
{"TEST`Bye", "TEST`Hello"}

But its still there. Let's try to clear everything:

ClearAll["TEST`*"]
Names["TEST`*"]
{"TEST`Bye", "TEST`Hello"}

Still everything is there! The same goes for packages and as Mathematica happily shares the kernels by default it's basically impossible for me to develop independent code because of thousands of shadowing warnings etc.

So my questions are:

  1. How can I clear a context or package?
  2. What is your workflow in developing individual Mathematica packages that are independent of each other and can be loaded on demand?

Update:

  1. Obviously use Remove instead of Clear. Thanks to the commentators.
  2. Have a look at Creating Mathematica Packages

0 Answers0