Import and Include

BlitzMax Forums/BlitzMax Programming/Import and Include

Twinprogrammer(Posted 2014) [#1]
Hello,

I was wondering what the differences between import and include are.


H&K(Posted 2014) [#2]
They are nearly the same.

Include is "paste" the file here. Which is then compiled
Import is, let me use the commands/functions in the file.

Normally you use Import if you think the (import) file inst going to be edited by you, or if its part of a library you wrote/3rd party . And you would use include when you are just splitting the program into sensibly separated files.


*(Posted 2014) [#3]
Another thing to note is imported source is compiled as a seperate module at compile time so if you call other stuff in it it will make your file sizes bigger, it is best to use import to make modules that are encapsulated in their own source.

Include just puts all the source in one compile and goes from there.


Kryzon(Posted 2014) [#4]
The biggest benefit of using Import, like the poster above said, is that the file is compiled separately, and BlitzMax will only recompile it again if it's modified.
This means that a project with Imports will always build substantially faster than if it used Includes.

The problem is that your Imported files need to be standalone for this to work. That is, two imported files can't depend on the declared objects inside each other since you can't forward-declare in BlitzMax (something that you can do in C++ to skirt this problem).
The name of this problem is "cyclic references," either file depends on the other.


Twinprogrammer(Posted 2014) [#5]
OK, got it. Thanks, guys!