Use Get; Need only loads the package if is not loaded at all. Sometimes you need to be careful and use ClearAll on the variables in the package.
Should it be in the notebook or in the . M file? – Dror Dec 9 at 9:37 1 In the .
M file. Say you edit a function that changes it's signature, if Get the file the old definition is still in the kernel.To avoid that use ClearAllmyFunction;myFunctionblab_,blah_,blah_:=... – ruebenko Dec 9 at 9:55.
As an alternative to using simple Get, as sugested by @ruebenko (which is a good advice), you can try using a package I wrote called PackageManipulations`, which does what you want. It is available here. There is a notebook with examples illustrating how it works, also availabe at the page I linked.
The package can reload, clear or remove a given package (context). The function PackageReload specifically will do what you want. It does use Get or Needs under the hood, but in addition it will track the so-called "escaping symbols" (symbols which are publicly exported but have no usage messages, and may be "leaking" the implementation details), and optionally can resolve the shadowing problems in favor of the package being re-loaded.
Note that PackageReload will automatically call Unprotect and ClearAll on package's symbols, therefore addressing the issue mentioned by @ruebenko. You can find more details in the example notebook which comes with the package. Note that, while I used it myself many times, I don't claim it is bug-free :).
Time to look closer at your 'Additional Resources' ;-) – nilo de roock Dec 9 at 11:19 1 @nilo de roock Unfortunately, that section has been the same for about 3 years now (this is really pathetic). I have a lot more that I would like to add there, but so far didn't have enough time to properly package, polish and test. Hopefully, I will update that stuff soon enough.
– Leonid Shifrin Dec 9 at 11:41 @LeonidShifrin: Thanks for the addition. I tried to add it to my package's beginning (after Unprotect@@Names"curveAnalysis*"; ClearAll@@Names"curveAnalysis`*";` and before the first usage). In the test notebook I reverted to Needs.
Then I tried to reload the package after changing it (without using Quit), but the changes didn't apply. I had to either use Quit or reuse the Get alternative. – Dror Dec 12 at 8:24 @Dror The code I posted should work - I specifically added the test code above and tested it myself.
I did not mention it, since I thought this was clear from the context, but with this addition you must use Get in any case. Needs does not reload the package once it has been loaded. In fact, as I already mentioned also, the function PackageReload from my PackageManipulations` does all this work for you automatically, including choosing which one to call (Needs or Get), calling Unprotect and ClearAll on all package names (incuding sub-contexts), and a few other things.
– Leonid Shifrin Dec 12 at 8:36 @LeonidShifrin: I'm afraid it wasn't that clear to me. Any way it works now. See my addition to the question for further details.
– Dror Dec 12 at 9:35.
The easiest method is to use Clear or, better yet, ClearAll on the exposed symbols in your package at the very beginning of your package, as follows BeginPackage"SomePackage`"; ClearAll ASymbol, AnotherSymbol, ...; This ensures that you have a clean slate whenever you load it. This is easier once the package is more stable, but I find if I don't do this when I'm initially developing a package, it doesn't get done.
1 I added (as I saw it in some example) Unprotect@@Names"package*"; ClearAll@@Names"package`*";` at the beginning of my package. Is this equivalent and addresses the same problem? – Dror Dec 9 at 19:25 2 @rcollyer This would be a perfect solution if either packages would not evolve or the package writer would be very disciplined (I wasn't).
I was doing this as well for a while, but almost every time I got some new functions added and forgot to add them to ClearAll. When I got tired of nasty bugs resulting from older definitions staying with the new ones for those functions, I wrote the package I mentioned in my answer. And I have been happy (regarding this issue) ever since :) – Leonid Shifrin Dec 9 at 21:40 @LeonidShifrin, I did say it was the easiest to implement, I did not say it was a robust solution.
But, what about Dror's variant? Wouldn't that work? – rcollyer Dec 10 at 2:03 @rcollyer It would not be the whole story because it would only clear the symbols in the main context.
One would also need to call ClearAll on all sub-contexts (usually, this is just Private` ). With this correction, it would probably work. This is pretty much what my package does, but it does all that automatically, and has some additional functionality.
– Leonid Shifrin Dec 10 at 9:46 @LeonidShifrin: Can you please write the explicit code that you think I should add in order to have my approach robuster? Thanks. – Dror Dec 10 at 10:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.