Re: Re: variable "K"? (Really strange behavior . . . )
- To: mathgroup at smc.vnet.net
- Subject: [mg69253] Re: Re: variable "K"? (Really strange behavior . . . )
- From: albert <awnl at arcor.de>
- Date: Sun, 3 Sep 2006 23:46:57 -0400 (EDT)
- References: <ed6918$jho$1@smc.vnet.net> <200609011041.GAA25571@smc.vnet.net> <acbec1a40609010800w611c1bc2h322f089ea527b535@mail.gmail.com> <edae60$qdh$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi AES, > The problem arises if it's your practice (as it is mine) to start > your notebooks with Remove["Global`*"] as the first Input cell, and > then define various functions and modules in the immediately > following cells, carefully avoiding assigning any numerical values to > any symbols or parameters in those functions and modules until after > all those definitions have all been completed. > > Many of the symbols or parameters in those functions or modules will, > of course be given numerical values further down in the notebook, > when you run specific cases, but starting the notebook with > Remove["Global`*"] means (or *should* mean) that if you run the > notebook once, then re-run it from the top, the initial functions and > modules will not be contaminated by numerical values assigned in the > previous run. > > The problem is, K is apparently *not* cleared out by > Remove["Global`*"], and no warning of this is given; and hence if > you've used K as a variable in these initial definitions, the value > of K from the previous run is "hard-wired" into the initial > definitions on the following run -- whether that's what you intended > or not. I think it should be obvious that Remove["Global`*"] is only doing almost what you want, and only by chance. As the documentation will tell it removes all symbols in the context "Global`". If you define (own)values for symbols in other contexts, may that be "System`" as in the case you mentioned or in any other context, e.g. mycontext`var = 5, these will not be removed, and there is no reason to believe they should. Nothing wrong with Mathematica, I think. The fact that variable names starting with uppercase letters can conflict with internal names is well known and documented. If for readability you want to use short uppercase letters for variable names, I would suggest to use the script-Letters. These you can input from a palette or with Esc-scA-Esc for a script capital A. I use this all the time and have never had problems with it. For cleanup of the kernel you should check the package CleanSlate`, because that AFAIK has been made to provide the functionality you are "misusing" Remove["Globals*"] for. If CleanSlate` will not cleanup System`-Variables that have been changed, than you could ask the author of that package (Todd Gayley I think) to include such a functionality or provide it yourself. hth, albert
- References:
- Re: variable "K"? (Really strange behavior . . . )
- From: AES <siegman@stanford.edu>
- Re: variable "K"? (Really strange behavior . . . )