No, I mean using the "*" operator to dereference an invalid pointer:
int* p; // Not initialized
int a;
a = *p;
This will ofcourse also crash in normal C/C++, but it would be nice (especially for beginners), if there was a helpfull error message here, atleast indicating what kind of error was made. Like in C-script I remember getting invalid pointer errors for example when you use "player" when it isn't pointing to anything yet:
Code:
function main()
{
if(player.x == 10)
{
}
}
Crashes in Lite-C. In C-Script, I get "Empty pointer in main: (player.x == 10)
There are many other things that don't necessarily cause crashes, but still had more usefull error messages in C-script. For example array out of bounds:
Code:
var a[10];
var b;
function main()
{
b = a[11];
}
Didn't crash in my test program, but is certainly an error. In C-Script I get: "Invalid array index in main: b = a[11];". I understand that detecting this with variable indices requires storing the array length somewhere, so this can get complicated.
I think it's worth to sacrifice some performance benefits for ease of use. If you want performance, you can use C++.
Besides improving the debuging, I think it's important to educate the users more.. I've seen people use "var*" throughout their application where they meant "var", just because the manual mentions that every struct in Lite-C gets a * after it's type declaration... This actually seemed to work because var* can just store numbers as long as you don't use them as pointers. But this shows that many people don't know what a struct or a pointer is. So they're bound to make mistakes.