Druntime configuration ideas #42
IgorDeepakM
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As I'm working with trying separate the OS dependent code in druntime I quickly realize that some kind of configuration is needed. It was already suggested that configuration files was going to be used, I think that would do the trick just fine.
Currently in my changes I added a large ugly version switch in order to select and import the appropriate OS implementation file. It was suggested that in the future the it would import the implementation based on a subfolder like this.
mixin("import core.sys." ~ config.osSysDir ~ ".sync.osmutex");
This has led to a lot of file duplication with files looking like this.
As many OSes just use the generic POSIX implementation. So why not make it more specific like this.
mixin("import " ~ osMutexImportPath);
where
osMutexImportPath
is a enum string in the configuration file.enum string osMutexImportPath = "rt.sys.posix.osmutex";
By this method for example Solaris which almost always use the generic POSIX implementation can import that implementation directly in mutex.d
Right now I have a very large ugly version swith in mutex.d. Why not move this very ugly version switch to the configuration file instead. There is a main configuration that does a public import on the OS specific configuration file like this.
Then the main config file rt.druntimeconfig (or where ever you want to place it) will be imported by the implementation files that needs it in order to obtain the configuration.
This will reduce the files needed. Also more configuration can be added to the configuration files as needed. Also specifying the import path directly for each implementations like osmutex, also enables you to select files outside the opend directory structure if your code is outside it and like an OS support package similar to Rust broke out the OS support implementation.
Solaris for example is almost exclusively POSIX and making public import from the POSIX implementation seems like a detour to me.
This is work in progress and I find out new ideas all the time. Tell me what you think.
Beta Was this translation helpful? Give feedback.
All reactions