2
$\begingroup$

I have two packages "packageA" and "packageB". The function names across packageA and packageB are unique. No two functions have the same name.

When I issue the commands in a notebook:

Needs["packageA`"];
Needs["packageB`"];

I get a Symbol appears in multiple contexts for every function in packageB`.

My questions are:

  1. Is it possible to load two packages at the same time?
  2. Is there any way to have two packages with the same function names (is it really possible to have local methods in a package)?
  3. Is there anything in Mathematica that works in a similar fashion to a namespace in .net languages?
$\endgroup$
7
$\begingroup$

This is all covered in the documentation. To answer your specific questions:

  1. Yes, just call Needs or Get more than once.
  2. Yes, by setting up contexts correctly
  3. Yes, but in Mathematica they are called Contexts.

The issue is likely to be that you did not use a standard package structure to write your packages, including the Begin["Private`"].

See the answers here for more information.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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