I am interested to know what are the approaches to the organization of modules for programs. What is of interest is how to divide programs into parts and link these parts.

If you refer to any esoteric language that uses an original approach, I will be glad.

I will list what I already know in order not to bother the respondents:

  • Direct inclusion in the global namespace. When all characters (the names of class functions) are included as is, which strongly trashes the namespace. Languages : C, C ++ (true namespace s partially save), PHP, Ruby ( Module s save too), Scheme

  • Import as a module, the ability to explicitly specify the name for the included module (something like alias) and access the characters by that name. Global namespace is not littered. Languages : Java, Python, Haskell, D

In addition, in some languages, you can specify the name of the plug-in in runtime, in others not.

Actually the question is: are there any languages ​​or approaches that do not fall into any of the categories described above? Are there any languages ​​where even these approaches are implemented outside the box?

  • I suspect this will be another abstruse unanswered question. - Vladimir Gordeev
  • Time will tell. :) - Nicolas Chabanovsky ♦
  • Assemblers such as tasm, masm, nasm would also be included here. I did not understand the answer <<< You are interested in exotic approaches to splitting code into files, i.e. modularity and access to these modules. I gave examples of languages ​​where it is. Google, I think you will find a lot of interesting things - 111
  • one
    <i> When all of the characters (the names of class functions) are included as is, which is very cluttering the namespace. </ i> For C ++, this is incorrect, because the scope of a class function is this class. Those. This function does not directly litter the global namespace. For C, it is correct, because there are no classes, namespaces, etc., and functions are available wherever their definitions are. - gecube
  • one
    @mikillskegg, I also think that the TS is interested in the linguistic aspects of modularity, but just in case (perhaps because of the reason for closing the question) decided to throw information. - avp

2 answers 2

Languages: C, C ++ (true namespaces partially save),

More interesting is another thing: in C / C ++, the space of available identifiers is limited to the source file in which the name is defined. Accordingly, in order to be able to pick up a function, the variable from another file has to be unscrewed with the help of h-nicks. This is for the compilation stage. But on the link you can get an error about duplicate identifiers. Total what we have for C:

  1. to pick up an identifier from another module - an explicit definition is required in the file where it is used.
  2. there is a static keyword for an identifier to be available STRICTLY from one module without the possibility of use in others. Otherwise, as I wrote above, the linker error.
  • Thanks, about such behavior static did not know. - Vladimir Gordeev

Python is a language based on modules which is enough for any task. Use a simple import of the module and refer to it by name.

  • one
    This is the answer to the wrong question. And you exaggerate about any task. - Vladimir Gordeev
  • Well for almost anyone. I have not yet met the tasks that it was not possible to cope with in this language. - Loki
  • four
    This means that you simply considered the tasks very specific. - cy6erGn0m