Re: A kernel, multiple notebooks, and Global?
- To: mathgroup at smc.vnet.net
- Subject: [mg87738] Re: A kernel, multiple notebooks, and Global?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 16 Apr 2008 05:05:50 -0400 (EDT)
On 4/15/08 at 5:51 AM, siegman at stanford.edu (AES) wrote: >Pardon any awkward wordings here, but I may not have all the jargon >relevant to my query clearly understood. >Suppose that on a single-user computer I have several notebooks open >that address different parts of a common calculation, and thus share >overlapping sets of globally used variable names. >The broad question is then, how far can I go -- or what dangers may >lurk -- in treating these multiple notebooks as essentially one >unified notebook that just happens to be stored in multiple files >and appear on screen in multiple windows? The only real issue here is your being able to keep track of what is going on. That is I am confident, long before you run out of resources (memory etc) you will have too many windows to be convenient for your use. >1) For example, in terms of contexts or scopes, I'm guessing that >"Global is Global": the Global` context for all of these notebooks >is set by or recorded by the kernel, and at any one instant is >exactly the same for all these open notebooks -- right? Right. >2) Suppose a certain Input cell is present in exactly identical >form at some random (i.e., different) point in each of the >notebooks; I've been executing cells from all of the notebooks in >some irregular sequence; and then I execute this particular cell in >whichever of the notebooks happens to be most convenient for me. Right. But you will need to be careful about dependencies in each of the notebooks. >I assume the kernel is likely to be able to recognize which notebook >submitted these Input instructions. I think this implies more tracking done by the kernel than is the case. I believe the kernel simply sees every thing as a sequence of operations and simply sends results back to which ever notebook was the evaluation notebook at the time. That is, I don't believe once you have evaluated several expressions in several notebooks there is a means within Mathematica to find the notebook containing say the 10th expression that was evaluated. >But beyond that, unless this cell contains some code which directly or >indirectly identifies the notebook in which the cell resides, and uses >this information to modify the Input instructions, executing the copy >of this cell that resides in any of the notebooks will produce exactly >the same result, except for where it displays its output -- right? Right. But watch out for unexpected dependencies. It is really easy when working in this manner to miss a change in a variable in one notebook that impacts another notebook.