MathGroup Archive 2007

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

Search the Archive

Re: $CellContext

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77268] Re: [mg77139] $CellContext
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Wed, 6 Jun 2007 07:05:36 -0400 (EDT)
  • Reply-to: jfultz at wolfram.com

On Tue, 5 Jun 2007 06:23:51 -0400 (EDT), David Park wrote:
> $CellContext is something new in Version 6.0. What is its purpose? I have
> a palette from 5.2 that copies selected material, performs some
> processing on it, and saves it. There is another button that will paste
> the processed expression back into a notebook. It worked fine in 5.2 but
> in 6.0 it returns variable x, say,  as $CellContext`x.
>
> How can I convert this back to a plain x?

$CellContext is a symbolic placeholder in cell expressions (most typically 
Dynamic expressions inside of Cells) which indicates that the ambient context as defined by the CellContext option should be used (which allows you to wall off 
notebooks, cell groups, and cells from each other via automatically generated 
contexts).  This is to distinguish from the default kernel context, which would 
be $Context.  For example,

In[1]:= CellPrint[ExpressionCell[Dynamic[Context[a]],"Output"]]
Out[1]= Global`
In[2]:= 
CellPrint[ExpressionCell[Dynamic[Context[a]],CellContext->"Private`","Output"]]
Out[2]= Private`
In[3]:= 
CellPrint[ExpressionCell[Dynamic[Context[a]],CellContext->Cell,"Output"]]
Out[3]= Cell$$3566`

You'll see it a lot in cell expressions, but it's supposed to be replaced with 
the actual context whenever an operation goes to the kernel.  It's possible thatthis was overlooked in some cases.

Send me your palette (or better, the individual button if you can) and I'll have a look at it.  In the meantime, you can work around the problem by explicitly 
setting contexts (i.e., probably Global`) for the affected variables.

Sincerely,
 
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.




  • Prev by Date: Re: Re: Re: pure function to generate a list of
  • Next by Date: Re: NDSolve, Do loop, and Plot
  • Previous by thread: Re: $CellContext
  • Next by thread: Trouble with TraditionalForm in Mathematica 6.0