7
$\begingroup$

I'm trying to use this technique to keep variables separated between different notebooks. It seems to be working fine, except that variables turn black as soon as they are evaluated — any ideas why this would be happening? Here are some examples:

And with a variable that hasn't been used at all:

enter image description here

Suddenly it's black, even though it has no value:

$\endgroup$
6
  • $\begingroup$ I don't have time to tinker with this, but I think it could be addressed by setting one of the different styling options in Options[$FrontEnd, AutoStyleOptions] (also see in the options inspector) $\endgroup$
    – rm -rf
    Commented Oct 26, 2012 at 20:13
  • 1
    $\begingroup$ So this is a different solution to the problem of different notebooks/different contexts. What about using different kernels? You can add more kernels by going to the Evaluation menu and selecting Kernel Configuration Options. I have multiple local kernels that I'll use for just this reason. $\endgroup$
    – user4368
    Commented Oct 26, 2012 at 21:08
  • $\begingroup$ Behavior confirmed in version 7 on Windows 7. $\endgroup$
    – Mr.Wizard
    Commented May 23, 2013 at 14:27
  • 5
    $\begingroup$ I'm reasonably certain this is designed behavior - the variable coloring is only supposed to apply to the Global context. As an indication, in Preferences>Appearance>Syntax Coloring>Other the typical blue color is assigned to "Global symbols that have no value assigned". I'm not aware of any way of getting the syntax coloring to look at symbols in other contexts here, but maybe there is some trick. $\endgroup$
    – KAI
    Commented May 23, 2013 at 17:49
  • $\begingroup$ @KAI please consider submitting that as an answer. $\endgroup$
    – Mr.Wizard
    Commented May 29, 2013 at 6:22

1 Answer 1

3
$\begingroup$

I agree with this comment, so let me put here a wiki:

I'm reasonably certain this is designed behavior - the variable coloring is only supposed to apply to the Global` context.

As an indication, in Preferences>Appearance>Syntax Coloring>Other the typical blue color is assigned to "Global symbols that have no value assigned". I'm not aware of any way of getting the syntax coloring to look at symbols in other contexts here, but maybe there is some trick.

– KAI

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.