3
$\begingroup$

TLDR;
What is the mathematics foundation for the namespace problem? Can I reduce namespace problem to set theory or other math concepts/objects (lambda calculus, category theory)?

I'm doing an essay on concepts like namespaces, packages and modules in programming languages. Among other topics, I'm studing how to avoid names collitions and in particular how programming languages solve the problem. For example:

Given any programming language, suppose that we have following user defined functions (or other language specific "object") named $a$ and $b$:

function a () {
  // do something
} 

function b () {
  // do something
} 

And a function called $c$ that uses above functions:

function c () {
  a();
  b();
} 

If in the "context" above we defined another function called $a$, we would have a collision in function $c$ because it doesn't know what $a$-function implementation must use.

So to avoid name collisions a programming languages can implement namespace/package/module systems and let the programmer doing something like the following:

module alpha{
  function a () {
    // do something
  }
  function b () {
    // do something
  }
} 

module beta{
  function a () {
    // do something
  }
} 

And then doing:

function c () {
  alpha.a();
  alpha.b();
}

or

function c () {
  beta.a();
  alpha.b();
}

Thanks.

$\endgroup$
3
  • 2
    $\begingroup$ Often namespaces are generalized to be modules with an interface and multiple implementations, and multiple parameterized instantiations (think of objects as namespaces). In that case, you may want to look at existential types: cs.cornell.edu/courses/CS4110/2012fa/lectures/lecture26.pdf $\endgroup$
    – pron
    Dec 19, 2016 at 8:18
  • 9
    $\begingroup$ This is not a research-level question, please move over to cs.stackexchange.com and it's not clear what you are asking. It looks like you just need to consult a book on principles of programming language and read about type checking and the concept of typing context. $\endgroup$ Dec 20, 2016 at 7:32
  • 1
    $\begingroup$ "a" is nothing else than a constant that has as value a logic; you can model it as any other constant $\endgroup$ Dec 23, 2016 at 17:56

1 Answer 1

1
$\begingroup$

Looking around on google, I couldn't find much on this topic at all. However, I did find this thesis on arxiv, which I believe addresses this problem, albeit in a semi-roundabout way. As the author states in the conclusion

The goal of this work was to discover namespaces in mathematical notation given a collection of documents with mathematical formulae. This problem could not be performed manually: this task it too time consuming and requires a lot of effort.
To achieve the goal we proposed an automatic method based on cluster analysis. We noted that document representation in terms of identifiers is similar to the classic Vector Space Model. This allowed us to apply traditional document clustering techniques to the namespace discovery problem.

So cluster analysis seems to be something to look into here.

Hope this helps; I'll keep looking around for other resources.

$\endgroup$
2
  • 2
    $\begingroup$ If you need to Google the answer, and then you find something at random, but you're not reallty sure, do you think you should be answering the question? $\endgroup$ Dec 21, 2016 at 8:18
  • 2
    $\begingroup$ maybe @heather dosn't directly answer my question but his answer help me anyway for other reasons. I'm waiting for other ideas before accept the answer. thanks to all. $\endgroup$
    – baudo2048
    Dec 21, 2016 at 13:37

Your Answer

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

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