Think about the worse-cast complexity of unordered “shards”. Think about the semantics of commands with side-effects (it seems like the order would be essentially non-deterministic from load to load).
Each file reduces to a set of definitions (types, functions, constants) paired with a set of uses. The simplest comparator is “a given file’s definitions must come before another file’s uses” (assuming no methods are actually called during loading…).
In that case it seems much easier to just write the ordering down . Otherwise you and the loader are playing a weird game of telephone for uncertain benefit.
That page seems kind of circular to me. Basically it reads as:
- “files” define a specific interface (a class for PHP; a function for IDL and older Matlab; a
+x file for the Unix shell; etc.)
- you tell your compiler where to find things (load path)
But by that definition, Julia and Python have auto-loading for modules (assuming you have your load path set correctly, of course). C even seems like it has auto-loading for
includes (again assuming you’ve told the compiler where to look!).
In that case, for your loader or packages you could enforce a rule similar to IDL in that example (and older Matlab versions), which is “one global per file with matching filename”. Then the problem is easy. But that sounds really annoying to use (and it was really annoying in Matlab). Personally I would rather just write down the ordering explicitly, but I suppose it’s a matter of taste.