Q&A Warning if load Cardano3

Question.  When I evaluate

    Needs[“Cardano3`ComplexGraphics`”]
    Needs[“Cardano3`ComplexRoutines`”]

I get a warning message like:

    ComplexPoint::shdw: Symbol ComplexLine appears in multiple contexts
    {Cardano3`ComplexGraphics`,Global`}; definitions in context
    Cardano3`ComplexGraphics` may shadow or be shadowed by other definitions.

And then when I try to evaluate an expression using a Cardano3 function like ComplexPoint, for example,

    ComplexGraphics[{ComplexPoint[2+3I]}]

I get as output only some of the graphics but first an error message like:

    Graphics::gprim: ComplexPoint[2+3I]] was encountered where a Graphics primitive or directive was expected.

What causes this and how do I fix it?

Answer.  You forgot to load the Cardano3 packages before you used functions from them!

To fix the problem:

  1. Quit the Mathematica kernel.
    To do that, from the Kernel menu, select Quit Kernel and click the little Local fly-out box.  Then confirm your action by clicking the Quit button on the pop-up window asking, “Do you really want to quit the kernel?”
  2. Start all over again by loading the Cardano3 packages with those Needs statements.
  3. Only after that evaluate other expressions that involve Cardano3 functions.

The cause of the difficulty:  When you originally evaluated some expression involving ComplexPoint (or whatever Cardano3 functions is at issue), Mathematica keeps that name in the Globalcontext” (a Mathematica context is what computer scientists call a “namespace”).  That’s what it does with any name you use that it hasn’t been told about before.  And this is so even if you did not assign a meaning to ComplexPoint.

But then when you subsequently load the Cardano3 packages, one of them specifies a meaning for  ComplexPoint, and Mathematica wants to remember that definition under the Cardano3`ComplexGraphics` context.  But it knows you already used it in the Global context.  So the meaning of ComplexPoint in the Global context “shadows” the one you really want to use, that is, the one in the Cardano3`ComplexGraphics`

Next, when you try to evaluate an expression involving that same Cardano3 function, Mathematica is forced to use the definition from the Global context—”your” context—and so it does not have the Cardano3 definition available to it.

There’s nothing special about the Cardano3 packages in this respect.  The same thing would happen with any package you loaded after you already used a name that is defined in that package.

[Home] [News] [Exams] [Files] [Homework] [Notes] [About] [Links]