Why does MaxGUI require importing?

BlitzMax Forums/BlitzMax Programming/Why does MaxGUI require importing?

Adam Novagen(Posted 2016) [#1]
Title says it all. I've been fiddling around with MaxGUI lately, and I don't fully understand why I need to use Import maxgui.Drivers and Import maxgui.ProxyGadgets to build MaxGUI programs, when I'm not using the Framework command. I was under the impression that if no Framework was specified, BlitzMax would simply pull all the modules in automatically... Does it only import the BRL and PUB modules by default?


col(Posted 2016) [#2]
Does it only import the BRL and PUB modules by default

I believe it only pulls in the BRL modules and if any of them need the PUB modules then they pull them in themselves.

edit:- And when using the Framework command it only pulls in brl.blitz by default and all of the others need to be specified. Something like that :p


Kryzon(Posted 2016) [#3]
I had the same impression as col, that BRL was automatically included and it pulled the PUB modules it needed.
But I think all BRL and PUB modules are included automatically when you don't use Framework because of this piece of logic in BlitzMax\src\bmk\bmk_make.bmx:

			If app_type="bmx"
				For Local t$=EachIn EnumModules()
					If t.Find("brl.")=0 Or t.Find("pub.")=0
						If t<>"brl.blitz" And t<>opt_appstub MakeMod t 'MakeMod adds each module object to be linked with your program.
					EndIf
				Next
			EndIf
From: https://github.com/blitz-research/blitzmax/blob/a97b18fd62b211ecee464097180e0ebf2e7f12b7/src/bmk/bmk_make.bmx#L187

Why MaxGUI is not a part of the BRL namespace, I'm not sure. It might have something to do with when MaxGUI was being sold as a separate module.
It's completely possible to modify some of the MaxGUI files and include the entire folder in BRL, but I still prefer it being an optional module as opposed to be linked with every program, to keep the memory cost lower.


Adam Novagen(Posted 2016) [#4]
Interesting. Is executable size the only actual benefit to importing (or not importing) modules? I still find myself largely hung over with the habit of using Include, which I am aware stitches all the files together before sending them to the compiler but I don't necessarily see that as a bad thing.


Kryzon(Posted 2016) [#5]
Import speeds up compilation, which is mostly benefitial if you have a lot of code.

Using Include will always force that code text to be compiled. It always takes the same time.
Using Import will allow BlitzMax to build the imported files once and, as long as they aren't modified, keep them pre-compiled and instantly link them to your program the next time you build it.

This is not related to the 'Quick Build' option in the IDE, that's a different thing.

- - - - -
Though Include is essential in some moments, like when you have cyclic dependencies (two Types that reference each other in a Field or Extend).
Since in BlitzMax you can't do something like a 'forward declaration' that would eliminate this problem, you need to use Include so all these related Types are declared in the same code file.