Skip to content
vczh edited this page Jan 30, 2014 · 2 revisions

Module is the most important feature to enable the programming language to write large softwares. Although Tinymoe does not designed for such a scale like Office or Windows, but it still provide modules.

A module can be implemented in several files, each file has a module referencing list. The list only affect the current file. So if there are 3 files:

  • File A
module a

X
  • File B
module b
using a

Y
  • File C
module b

Z

Then

  • File A can only access X, because A using nothing.
  • File B can access X, Y and Z, because B using module a, B and C are the same module.
  • File C can access Y and Z, because B and C are the same module, but C using nothing.

We can clearly know that

  • Code in different files of the same module can access the whole module.
  • Code in the file can access modules that uses in this file.
  • If code A and code B are the same module, the using list of A does not affect the code in B.

There are also additional rules for resolving names

  • If module a references module b, module a and module b declare a function in the same name, than in the code in a, the function in a will overrides the function in b.
  • If module a references module b and module c, module b and module c declare a function in the same name, then in the code in a, the function in c will overrides the function in b.
  • Argument names or variable names in functions cannot override accessable symbols outside.