Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

"unload" a package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70814] "unload" a package
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Sat, 28 Oct 2006 05:21:58 -0400 (EDT)

Hello to all.

I wondered how someone can "UNLOAD" a package
without "kill" the Kernel?

That is, is there a command that does the opposite of Get or Needs?

After the Chriss Chiasson and David Park's responses (thanks a lot both
of you!!!) and their suggestion for using Remove I tried to experiment
myself, practise which resulted in a bigger query.

Before proceeding to my question Copy/Paste the
following in a notebook, select the Cells and execute the commands.

----------------------------------------------------------------------------------------------------------

Print[StyleForm["Version I work", FontColor -> Blue, FontWeight ->
"Bold"]]
$Version

Print[StyleForm["Load the package", FontColor -> Blue, FontWeight ->
"Bold"]]
Needs["Graphics`Graphics`"]

Print[StyleForm["Built-in Symbols inside the package", FontColor ->
Blue,
FontWeight -> "Bold"]]
Names["Graphics`Graphics`*"]

Print[StyleForm["An example", FontColor -> Blue, FontWeight -> "Bold"]]
DisplayTogether[Plot[x, {x, 1, 2}], Plot[2*x, {x, 1, 2}]];

Print[StyleForm["Remove all the Built-in Symbols\nof the package from
the Kernel", FontColor -> Blue, FontWeight -> "Bold"]]
Remove["Graphics`Graphics`*"]

Print[StyleForm["Check", FontColor -> Blue, FontWeight -> "Bold"]]
Information["Graphics`Graphics`*", LongForm -> False]

Print[StyleForm["Reload the package", FontColor -> Blue,
FontWeight -> "Bold"]]
Needs["Graphics`Graphics`"]

Print[StyleForm["Built-in Symbols inside the package", FontColor ->
Blue,
 FontWeight -> "Bold"]]
Names["Graphics`Graphics`*"]
Print[StyleForm["!!!", FontColor -> Blue, FontWeight -> "Bold"]]

Print[StyleForm["Kill the Kernel", FontColor -> Blue, FontWeight ->
"Bold"]]
Quit

Print[StyleForm["Re-re-load the package (...)", FontColor -> Blue,
FontWeight -> "Bold"]]
Needs["Graphics`Graphics`"]

Print[StyleForm["Built-in Symbols inside the package", FontColor ->
Blue,
FontWeight -> "Bold"]]
Names["Graphics`Graphics`*"]

Print[StyleForm["Kill the Kernel", FontColor -> Blue, FontWeight ->
"Bold"]]
Quit

Print[StyleForm["Re-re-re-load the package (...)", FontColor -> Blue,
FontWeight -> "Bold"]]
Needs["Graphics`Graphics`"]

Print[StyleForm["Built-in Symbols inside the package", FontColor ->
Blue,
FontWeight -> "Bold"]]
Names["Graphics`Graphics`*"]

Print[StyleForm["Clear all the Built-in Symbols\nof the package from
the Kernel",
FontColor -> Blue, FontWeight -> "Bold"]]
Clear["Graphics`Graphics`*"]

Print[StyleForm["Check I", FontColor -> Blue, FontWeight -> "Bold"]]
Information["Graphics`Graphics`*", LongForm -> False]

Print[StyleForm["Check II", FontColor -> Blue, FontWeight -> "Bold"]]
DisplayTogether[Plot[x, {x, 1, 2}], Plot[2*x, {x, 1, 2}]]

Print[StyleForm["Check III", FontColor -> Blue, FontWeight -> "Bold"]]
Needs["Graphics`Graphics`"]
Print[StyleForm["Again problem", FontColor -> Blue, FontWeight ->
"Bold"]]
DisplayTogether[Plot[x, {x, 1, 2}], Plot[2*x, {x, 1, 2}]]

---------------------------------------------------------------------------------------------------------------

And here comes my question!

Ok, with Remove["Graphics`Graphics`*"] you avoid to refresh the Kernel
in order to "unload" (...somehow..) the package.

However, in order to reload again the package you MUST refresh the
Kernel!
BUT, this is what I want to avoid!

The same holds true, more or less, for Clear.

Anyway for those that are interested in the subject,
there is forum for Mathematica (I think Chris Chiasson is responsible
for it; see http://groups.google.com/group/mathematica)
and look what someone answered me:

"I think that there is no reliable way to do this.
However, take a look at the CleanSlate package in
ExtraPackages/Utilities. The documentation is inside the CleanSlate.m
file. But keep in mind that this package is not very reliable.
You can also read about contexts. The functions imported from packages
usually reside in their own context."

What do you believe?

I really appreciate any guidance/further insight.
Thanks in advance for any response

Dimitris Anagnostou


  • Prev by Date: Re: GraphPlot
  • Next by Date: Re: DownValues and Cases
  • Previous by thread: Weights option to Regress command not behaving as expected
  • Next by thread: Re: "unload" a package