Huh, what a response to my arguments, you guys are sensitive about the
exit command.
My arguments were based on the fact that OFP (like any other program that reads files) expects the EOF to come at some point and thus it is checking for it already so putting the
exit there in addition is unnecessary.
I can not imagine a reason why BIS would program OFP so that after EOF it would not release memory that was used to keep the
local variables and the contents of the file if
exit was not used. That would be a very stupid thing to do with the script files which are not intended to stay in the memory after it has been read and commands in it have been executed. Forcing us to use some scripting command to release the memory is not a good idea... OFP has to deal with it without our help.
@HateR_KintThe 'white space' in your script file is not something magical for a programming language like C++ that it couldn't deal with. The empty line has to be marked somehow to the file and OFP will go through these lines too, all the way to the EOF. It's not my or OFP's fault if you put many pages of empty lines to your scripts...
And it has to do it like that, how else it would know a script had ended?
Well the answer is End Of File, a.k.a. EOF. Every file has an end and so do OFP script files. Arriving at the EOF, OFP will for sure know this is it. No going further from here.
Suma said somewhere that OFP does not have a script compiler/parser/whatever so OFP doesn't seem to read through the script before executing it...
This really has nothing to do with the
exit command or with the EOF. It doesn't matter
when OFP goes through the script file, it still notices the EOF.
@qqqqqqSorry if your feelings towards the
exit command were hurt, I didn't intend to do that.
I did not say that having
exit at the end of a script will cause lag. I said it is extra work for OFP (and for you too) because it's a scripting command that OFP has to deal with. OFP has to check the syntax of the command and only if it is correct then it is used, of course. And checking the syntax will take more time from OFP than simply just noticing that the file ended. This is common sense to me.
After finding
exit, OFP has to do whatever is on the
exit function. It can be the same code as what is executed when EOF is noticed by OFP.
It's the syntax checking part I am saying will make the usage of
exit slower than just EOF, because OFP has to check the lines contents first character by character (you might have done a typo there, how can OFP know in advance that you don't do typos?) and then using
exit can't be faster than just arriving at EOF because OFP is already expecting to see the EOF.
Huh. This is ridiculous but let's continue...
Ending with exit could significantly speed things up.
What would the magical things be that the
exit command does to speed things up? Maybe not releasing the memory used by the script and it's variables would be one way to speed things up momentarily, but that would lead to big problems later on, like filling the memory with garbage. So this is not possible and we already know this isn't true when it comes to how OFP handles scripts. Good job from BIS.
Quote:writing exit to the last line of your scripts is totally pointless
Wrong. This is a significant expansion on your original unsupported assertion that writing exit merely slows the game down. Even if it does slow the game down it indicates to anybody editing the script - including yourself six months later - that the script is finished and there aren't 20 more lines that have been deleted by Windows for no reason and without a trace. It also makes a comment line "this is the end of the script" superfluous. It also allows you to add at the end of the file comments or other information useful for explaining, editing or generalising the script. It is also aethestically more pleasing, thereby making the world a better place. It also has a pschological benefit since it bestows a sense of completion on the proceedings.
Well if you want to mark the end of files just so that you will know it's the end, then by all means do it. I don't care how you spend your time.
Your assertion is not logically sound.
It is my friend. Trust me on this one.
@MikeroYes that's one issue but I trust BIS so much that I believe their parser is good enough to know how to cope with that kind of situations, and still be faster than
exit<eof>.
@PlanckThat's how I also thought it works and thus it makes sense that checking the syntax of the line where
exit is will take more time than not having an
exit command at the last line.
CONCLUSIONS1. Use
exit if you want to at the last line of your scripts, but when writing it to your files please always remember that it is unnecessary. You can't hurt yourself or anyone else by using it, and it definitely is not a source of lag in your scripts so this is not a big thing. It's a
very small thing but hey at least we managed to build up a good conversation about it!
2. EOF has been found and I am closing this file now and releasing the memory used by it for better purposes.