Silly question about userlibs

Blitz3D Forums/Blitz3D Programming/Silly question about userlibs

jfk EO-11110(Posted 2011) [#1]
Hi, although I am one of the Blitz vets, from time to time I still have some questions.

When I have a userlib with a declaration of say Print%(n), does that overwrite the original Blitz3D Print command, and does that mean I always have to watch all userlibs carefully in order to prevent changes in the compiler result? (somebody could make me use his malware, by calling "Print"?) Ok, if so (and I am afraid it is), what happens if Print is declared/overwritten in a userlib, but the DLL that holds the new Print command is not part of the distribution, will this cause a "userlib not found" error, or is it going to use the original Print instead?

Thank you.

Last edited 2011


Yasha(Posted 2011) [#2]
Well I just tested this...

Creating a .decls file that links to a nonexistent DLL didn't affect B3D at all; it just used the regular Print. However, Print can be overridden from within B3D (as explained in the documentation), so what I would guess happens is that when names conflict, the compiler has some kind of strategy for choosing one over the others; in the case of the .decls file, it presumably is able to take the lack of a DLL as a sign to keep looking, and eventually found the builtin function (on the other hand, I didn't actually make a DLL so maybe it just can't override builtins from userlibs).

does that mean I always have to watch all userlibs carefully


Yes? Even if you're using several libs it shouldn't take you very long to go through the declarations listings (note that B3D won't import all functions that the DLL exports, only the ones listed in the .decls). After all, you only have to do this once, and you should probably be doing it anyway just to know what there is and how it interacts with things.


jfk EO-11110(Posted 2011) [#3]
You're right about that, although this probably should be communicated somewhere in the docs. It may be unlikely that somebody would try to harm people, but it could also cause problems by mistake. Incompatibilities with existing code for example, and one could spend a month, searching for the problem in his code that is using Blitz commands only.

FastExt for example overrides CameraClsColor and adds a fourth parameter "alpha#". When you hit F1 then the status bar help even shows the new syntax.