4 ms·
The idea of forcing modules to be defined in files with a deterministic way to pair module names and file names seems pretty reasonable. Two examples come to my
by ziotom78 8y ago
The idea of forcing modules to be defined in files with a deterministic way to pair module names and file names seems pretty reasonable. Two examples come to my mind:
- Go doesn't place requirements to the name of files defining a package [1]. However, it has a preprocessor neither, so the problems described in this article (specifying the module name within an #ifdef) are impossible.
- FreePascal has a preprocessor [2], but it defines a deterministic algorithm [3] to find the files containing a unit (the FPC equivalent of a module). Moreover, the compiler creates two files for every unit: a .o object file, and a "unit description file" [4], much like the C++ proposal.
It seems that FPC's case is the most similar. I think the author is right; the C++ committee should adopt a deterministic way to find the name of the files defining a module.
[1] https://golang.org/ref/spec#Packages https://golang.org/ref/spec#Packages
[2] https://www.freepascal.org/docs-html/current/prog/progse4.html#x135-1360002.1 https://www.freepascal.org/docs-html/current/prog/progse4.ht...
[3] https://www.freepascal.org/docs-html-3.0.0/user/usersu7.html https://www.freepascal.org/docs-html-3.0.0/user/usersu7.html
[4] https://www.freepascal.org/docs-html/current/prog/progse13.html#x151-1520004.1 https://www.freepascal.org/docs-html/current/prog/progse13.h...
- ithkuil 8y ago> - Go doesn't place requirements to the name of files defining a package [1]. In Go, the import path and package name are two distinct things: the import path locates and identifies the package, while the package name acts as the default name for scoping qualified name exported from that package. Furthermore in Go the file names are not part of the import path: the name of the directory containing the files that together define a single package is part of the import path. An imperfect analogy with C++ would be: - Go import paths <-> path to the included file (header) - Go package names <-> a namespace inside that included file. - Go package filenames <-> sections within the included file