Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: ClearAll ?? or what

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102830] Re: ClearAll ?? or what
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Fri, 28 Aug 2009 05:42:52 -0400 (EDT)
  • References: <h7371j$b28$1@smc.vnet.net> <h75nba$p3g$1@smc.vnet.net> <h77nb8$s5d$1@smc.vnet.net>

Hi,

>> Remove["Global'*"]

I just wanted to make clear it must be a ` not a ' to work at all. Just
because I think this could have been the OPs actual problem.

> The problem (a minor one) is that if you do this, then the first time 
> you execute such a notebook in a newly opened Mathematica session, you 
> will get the "error" message:
> 
>    Remove::rmnsm: There are no symbols matching "Global`*". >>

a message is a message and an error is an error. I think this is not
meant to be an error message, but a warning message, and I think it is
there for good reasons: Remove is not only useful for cleaning the
global namespace at the beginning of a notebook, and in other use cases
you probably want to see that message. It is another question whether
the formulation of the message is adequate and whether it would make
sense to make error and warning messages distinguishable...

> I put "error" in quotes here because (a) so far as I can see you haven't 
> really damaged anything by doing this, and (b) this shouldn't be called 
> an error in any case, at least if you live by the standard computer 
> science wildcard convention that "the asterisk character ("*") 
> substitutes for any zero or more characters".
> 
> The history is that doing this wasn't an error through several early 
> versions of Mathematica.  It became an error sometime around v4? 
> or v5?.  Why? -- who knows?
> 
> The solution, so far as I can see, is to use
> 
>    x; Remove["Global'*"]
> 
> as the first line in all your notebooks.  Can this do any harm?

Not really, but there always has been a well documented way to switch of
messages that you don't want to see (On and Off), and since version 6 it
is even simpler to do this locally and for "expected" messages only:

Quiet[Remove["Global`*"]]

or, if you are very careful and don't want to miss any unexpected
warning when evaluating the Remove:

Quiet[Remove["Global`*"],Remove::rmnsm]

hth,

albert


  • Prev by Date: Re: ClearAll ?? or what
  • Next by Date: Re: accumulate coefficients of a polynomial
  • Previous by thread: Re: ClearAll ?? or what
  • Next by thread: Re: ClearAll ?? or what