I've been trying to rangle the problem of programming language package/modules/etc. I'm not sure how to handle them in Odin but the current approach of having every file be a scope is probably not a good idea in the long run. I did want people to write single file libraries as the norm because this just means you can drop a file in and don't worry about anything else. However, for bigger projects, having multiple files for a single "package" is very useful. So the problem I have is determining what is the best approach to handling multiple file packages, if they are necessarily, and if single file libraries are possible along side multiple file packages.
To me, a multiple file package would have to consist of a directory with source files in. The best approach to this that I have seen is Go(lang). There are many other problems to Go (such as absolute paths) but the general idea of the "directory is the package" is okay. Its approach is borrowed slightly from Modula.
The other approach is the Python approach and still have the file be a scope but allow for a special file in a directory (__init__.py
) to treat the directory as if it was a file. This problem does mean that the author of the library can manually organize what they want to be exported or not my explicit declaring it in the __init__.py
file. However, if the user really wants to use the internals, they can.
So my question to everyone here is, is the ideal of single file libraries even a problem outside of C and C++ and is passing around a directory contain the files okay, even if it a single file? There is no perfect solution to this problem, only trade-offs.
If anyone has a preferred approach to this problem, I would love to know as I just cannot find an approach I like.
n.b. I am literally nearing feature completion in Odin and I just want to tackle the final big problems