Most people hate compiler errors and wish they would just go away, but I find them infinitely useful when tracking down particularly pesky problems. The only thing that would make it easier would be if I would define my own, to make sure my code has a much less chance or generating bugs at runtime.
How this would work, I guess would be such as a simple if() statement. It works like regular DM code but is read through when compiled. It takes this new error and checks the .dm files for anything that breaks the custom errors new rules. A simple definition of a compiler error might be placed into the .dme file, and could look something like this:
#define_comp_error //defines a new compiler error
{
DefineVar("apple", 'example.dm', /mob/tree/var/apple) //a built-in proc that takes three args, the first argument is the name of the newly defined compiler variable, the second is the .dm file to look through, and the third is the type path for the variable in question.
if(!apple) //If apple is null or 0
COMP_ERROR("var/apple much be a non-zero number") //This other built-in proc would output the message in the message box and points to the line where apple has ever equaled 0 or null.
}
I guess while you're making a custom errors message, you can also do warnings as well. Multiple Variables could be defined and checked either individually or against one another.
This would be very tricky to incorporate user-defined compiler errors, but if it could be done in a practical way, It would be an invaluable tool for developers. All developers make accidents in code, if they accidentally make a variable 0 that wasn't supposed to be, this could point out their mistake before really big problems arose. Does anyone else have any thoughts on the usefulness that this tool might bring?
I use it to check if #debug mode is defined or not so I don't forget to turn it off before packaging.