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:
- How can I clear a context or package?
- What is your workflow in developing individual Mathematica packages that are independent of each other and can be loaded on demand?
Update:
- Obviously use
Removeinstead ofClear. Thanks to the commentators. - Have a look at Creating Mathematica Packages
Remove[TEST'Bye]. – Marius Ladegård Meyer Aug 07 '15 at 17:20Clearclears values and definitions for symbols, but it does not remove the symbols themselves. That is whatRemoveis for. Also, it seems to me that the second part of your question is almost entirely separate from the first. You may want to take a look at the previous discussion on Creating Mathematica Packages. – MarcoB Aug 07 '15 at 17:49Clear.Removeis exactly what I want, thanks. This answers part 1. of my questions. How do you deal with 2.? – Thomas Fankhauser Aug 07 '15 at 17:53