Mafia can handle multiple imports of the same redundant file such as
import <zlib.ash>; and mafia will treat the second import as redundant since it knows it was imported already. But Mafia can't handle the issue of circular inclusion, as you've noticed.
Let's say you had a setup like so:
testy.ash:
Code:
import <testy2.ash>;
import <testy3.ash>;
import <zlib.ash>;
void main()
{
hello();
world();
}
testy2.ash:
Code:
import <testy3.ash>;
import <zlib.ash>;
string getWorld()
{
return 'World';
}
void hello()
{
print(getHello());
}
testy3.ash:
Code:
import <testy2.ash>;
import <zlib.ash>;
string getHello()
{
return 'Hello!';
}
void world()
{
print(getWorld());
}
To solve the circular inclusion problem in the above, the solution is simply to create a
dependencies sort of directory. In Ezandora's Guide, she call this directory
Support. You'll also need to resolve the issue of the two files testy2.ash and testy3.ash relying on each other's functions. To do this, you'd predefine the functions, which you'll need to do inside an import since you can't predefine functions before an import.
So you can get all the above working with:
testy.ash:
Code:
import <support.ash>;
import <zlib.ash>;
void main()
{
hello();
world();
}
support.ash:
Code:
import <support/testy1.ash>;
import <support/testy2.ash>;
import <support/testy3.ash>;
support/testy1.ash:
Code:
string getHello();
string getWorld();
support/testy2.ash:
Code:
import <zlib.ash>;
string getWorld()
{
return 'World!';
}
void hello()
{
print(getHello());
}
support/testy3.ash:
Code:
import <zlib.ash>;
string getHello()
{
return 'Hello!';
}
void world()
{
print(getWorld());
}
Notice I didn't need to remove the multiple imports to zlib and the above will work fine when you execute
call scripts\testy.ash, although you'll still need to wait for zlib to load before seeing its simple Hello! World! output. Then, whenever you need to import
testy2.ash, for example, into some other file, simply import
support.ash instead. You can import it as a dependency into each file in your project in a redundant fashion, provided you're working around the circular inclusion issue in a similar fashion as I've described.