Hi,
I've studied the Module/Import system of the D language (dlang.org). D is a
language that tries to be a better C++. It's good to see that there are lots
of similarities between D and C2. This means that more people make the same
choices, which probably means that can't be that bad.
Similarities are:
- Concept of Package(C2)/Module(D)
- Package/Module have public/private symbols
- D static import are equal to C2 use
- D non-static import are equal to C2 use local (allows symbol use without prefix)
- Use(C) / Import(D) statement
- Import Aliases: use as (C2) / import io = c.stdio (D)
Differences are:
- D modules are single file, whereas C2 Packages can consist of multiple files
- D allowes Modules to be prefixed with a 'Pakage', c.stdio
- C2 has a build-system, D uses external one (like Make)
- D allows public import, C2 doesn't have this concept
- D allows multiple import in 1 line: import a,b, C2 doesn't
- D allows scoped import, C2 doesn't
- C2 doesn't need the module scope operator like D (.x)
I'm very interested in the public import feature. Does anyone have experience with this
(drawbacks, large-scale problems, advantages?)
Another think I'm still thinking about is the concept of something bigger than
C2 Packages. In D these are called Modules, but D also has a concept of Package.
The only use I discovered was that the compiler automatically looks for pkg.module
in pkg/module.d. But maybe in C2 we can use this for something else..
Finally, I think 'Module' reflects the meaning a bit better than 'Package', so
maybe C2 will also follow this. Package was currently chosen to create distinction
from clang's 'Modules' concept.
Anymore?
Bas