I need to evaluate
Needs["GraphUtilities`"]
before I can use functions such as GraphPath[]. When I do so, some functions get colored red, but still work.
Why does this happen and can I change this?
|
I need to evaluate
before I can use functions such as Why does this happen and can I change this? |
||||
|
The red colouring indicates shadowing — i.e., when a symbol originally in a particular context, is exposed to the current context path, thereby clashing with another symbol of the same name in a different context, also on the context path. Example of shadowing:Here is a short example that demonstrates this. Try it out in a fresh kernel (call
So far, all's well and you see the symbols coloured the way you're used to. Now expose
You'll now notice that both the
For more information on this, you can read about shadowing in the documentation and also this article by David Wagner in the Mathematica journal. Which definition is used in case of a conflict?The definition that is used first, in the case of shadowing, is the one belonging to the context that appears first in In the above example, I used
Now quit your kernel and do the same, except now you place the new context at the end. You can see that the definition used is that of
Incidentally, it is also possible to trigger this shadowing warning (red colour) even if there isn't a real conflict. This can occur if the same context appears at different positions in Changing the colour of the warningTo change the colour from red to your favourite, go to
|
|||||||||
|
f[x_] := Module[{x}, x]. You can actually change these colours inPreferences > Appearance > Syntax colouring > Errors and warnings. By default they're all the same damn shade of red (I have different ones for each). CHM, to answer the last line of your question, the above is where you can change this colour. – rm -rf♦ Mar 21 '12 at 14:03