Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In many programming languages one can define a namespace

with namespace abc

How can the similar be done in Mathematica? The Module and Block commands, can somewhat mimick this, but it is only in the command, it doesn't act as a definition.

How can this be done in Mathematica?

share|improve this question
Have a look at Context. – b.gatessucks Sep 24 '13 at 7:38
Ah, so with context I can do amass=2, bmass=3. Is there any way to define a block, where everything inside inherits that context? – Oskar Sep 24 '13 at 7:53
@Oskar It sounds like you want to create packages. Please see: (29324). Be aware that you cannot use Begin and End in a Module without great care; see: (8295) – Mr.Wizard Sep 24 '13 at 7:59
Here are two links to documentation pages relevant to your question. Namespace Management and Package Development. – m_goldberg Sep 24 '13 at 9:48
Perhaps this will help clarify things for you. In Mathematica, namespaces are the called contexts and packages provide the means for defining persistent namespaces. – m_goldberg Sep 24 '13 at 9:58

In Mathematica, $ContextPath contains a list of the contexts where the definition of a symbol is sought (when that symbol has no namespace qualifications). You can use

$ContextPath = Prepend[$ContextPath, "abc`"]

to achieve what you asked.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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