How to check that import module will succeed?
Andrey Zherikov
andrey.zherikov at gmail.com
Fri Jul 26 03:42:58 UTC 2019
Is there a way to check whether some module, say "foo", is
available for import before doing "import foo"?
I want to create a function that imports module if it's available
or does something else otherwise. So I think the code should look
something like this:
mixin template my_import(alias module_name)
{
if(module_name is available)
mixin("import "~module_name~";");
else
pragma(msg, module_name~" is not available");
}
mixin my_import!("std.stdio"); // == import std.stdio
mixin my_import!("unknown_module"); // == pragma(msg,
"unknown_module is not available")
More information about the Digitalmars-d-learn
mailing list