3 ms·
They should really look at how OCaml modules work, since they solve all the same problems already, with desirable properties like separate compilation and easil
by rwmj 9y ago
They should really look at how OCaml modules work, since they solve all the same problems already, with desirable properties like separate compilation and easily discoverable mapping of module name to source file.
The drawback of OCaml modules is that all dependencies must form an acyclic graph, which can be a pain sometimes although there are well understood workarounds.
- zem 9y agothe other huge problem is the poor support for hierarchical namespaces at the package level. nothing like linking your code with a library and having things break because you have a module name clash
- rwmj 9y agoYes, if you give all your modules a generic "toplevel" name like "Utils". However if you use underscores to namespace things you get something a lot like a hierarchy. You just need to have the discipline to call your modules "Myproject_Utils". Now I didn't say that OCaml has a perfect module system, although some of the first-class module features are stunning, but my point is that it solves a lot of the problems that this C++ guy is complaining about.
- zem 9y agoright, that's the standard workaround, but it really seems like something the compiler should be doing for you. i find it a very surprising wart in an in general very well-designed module system.
- DoofusOfDeath 9y ago> The drawback of OCaml modules is that all dependencies must form an acyclic graph, which can be a pain sometimes although there are well understood workarounds. Can you elaborate on that? It's hard to imagine a sane build system where the dependency graph contains cycles.
- lomnakkus 9y agoUsually, you just declare the module interface separately from the implementation. I don't recall there being any to "work around" e.g. declaring mutually recursive types in two different modules[1]. (And I don't think that's in any way sane, FWIW.) [1] Of course you can parametrize one of the modules with a signature declared elsewhere and the other module implement that signature, but that's really just regular old dependency-breaking, so I'm not sure that counts.