Imports that Import?

BlitzMax Forums/BlitzMax Programming/Imports that Import?

Picklesworth(Posted 2007) [#1]
I am sort of taking a wild guess here that it is possible to Import a source file that imports a module which has already been imported into the main program. (It is, right?).

Will this hurt my file size at all?

Here is a horrible diagram of what I am looking to do:

Main.bmx
	Import bleh.myMod
	Import "Addon.bmx"
	Import "AnotherAddon.bmx"

Addon.bmx
	Import bleh.myMod

AnotherAddon.bmx
	Import bleh.myMod

(It gets worse and more convoluted yet, but generally like that)


What I am worried about is BlitzMax not being clever and instead winding up with 3 instances of bleh.myMod. Should I not be worried, or should I be terrified?


H&K(Posted 2007) [#2]
not worried


Dreamora(Posted 2007) [#3]
BM uses LD to link (and import is nothing else than tell it where to link what with what) and LD isn't that stupid that it relinks the same thing multiple times into a single file from what I know.

But you would try to prevent such import lines yourself to prevent cyclic import problems at some point. If you know that Addon and AnotherAddon import bleh already you would not import it anymore.
This is actually quite a simple part of program design to know upfront what will be needed where ... if this is not know upfront you will run into much worse problems than "linking the same BMX multiple times" ... that will become the least problem you will have.


H&K(Posted 2007) [#4]
If you know that Addon and AnotherAddon import bleh already you would not import it anymore
This isnt true though (well not for everyone), each of my types imports what it needs to import, irrelevent of if types bellow it are already importing this stuff.

It makes editing and changing things easyer. (Ok possibly in final realease I might go though and remove the extra uneeded imports)


Picklesworth(Posted 2007) [#5]
Oooh, comprehensive explanation. Thanks, Dreamora.

Yep, the thing here is essentially dependencies.
If there was a way to set an Import's dependencies, that would be very cool. I don't think there is, so this seems the most tidy way :)

Cyclic imports are scary, though, so thanks for reminding me!