CellContext - Not ready for primetime use (opinion).
- To: mathgroup at smc.vnet.net
- Subject: [mg115980] CellContext - Not ready for primetime use (opinion).
- From: Jason Ledbetter <jasonbrent at gmail.com>
- Date: Fri, 28 Jan 2011 06:13:36 -0500 (EST)
Folk, Are any of you using CellContext with a user specified string successfully? e.g., CellContext->"someThing`". I've read the various threads on mathgroup that say "don't use that", but I'm sometimes stubborn. :-) I think I've come to the conclusion that CellContext just isn't ready for prime-time use outside of what WRI is using it for, despite it being in the documentation. Wolfram's support has been of very limited assistance as everything they come up with takes two steps back. Here's a simple example: --snip-- Remove[nb] nb=CreateDocument[]; SetOptions[nb,CellContext->"mine`"]; --snip-- In the resulting document execute: Dynamic[$Context] Dynamic[$ContextPath] You'll observe that the result is "mine`" which exactly matches the documentation and that the $ContextPath has been changed to include System` and mine`[1]. Let's suppose you want to now customize something in the resulting notebook like customize $ContextPath. The obvious way would be NotebookWrite and NotebookEvaluate (this was a solution provided by some DatabaseLink developer @ Wolfram)... Back in the original notebook execute the following and watch the results: --snip-- NotebookWrite[nb,"40+2"]; NotebookEvaluate[nb] --snip-- The Context/ContextPath get changed back to Global`... which means anything written to that document and executed through NotebookEvaluate[] completely tears down any explicit context/path that was setup through other mechanisms (like CellProlog[2]). [1] This brings up a couple of issues.. for example customizing $ContextPath without user intervention to include things like DatabaseLink`, etc. [2] This leads to other novel problems... DockedCells get a different context/path than that of the notebook itself resulting in situations where buttons in the dock only do the correct thing on their second action... -jbl