Use of "return;" and other little oddities
Posted: Sun Dec 03, 2006 4:39 am
I've been told on several occasions that it's a real NO NO to ever have a simple
return;
without at least setting a 0 value to it.
Even if the calling program never reads the return value, perhaps it's still a wise thing to do?
Fair enough, but what's the correct way to terminate a program rather than a function?
I've seen lots of scripts with return; in the program body, but maybe we should be using exit; instead? Does it matter in the slightest? Not that I've seen exit documented.
I also find it curious that program/endprogram statements are in fact not necessary to compile a script - ie ecompile doesn't generate any errors.
Or even that you can put a ; at the end of the if() line or not. Compiler doesn't care.
Sorry to bring these up, it's been in the back of my mind for years but I never got around to checking up on them before.
return;
without at least setting a 0 value to it.
Even if the calling program never reads the return value, perhaps it's still a wise thing to do?
Fair enough, but what's the correct way to terminate a program rather than a function?
I've seen lots of scripts with return; in the program body, but maybe we should be using exit; instead? Does it matter in the slightest? Not that I've seen exit documented.
I also find it curious that program/endprogram statements are in fact not necessary to compile a script - ie ecompile doesn't generate any errors.
Or even that you can put a ; at the end of the if() line or not. Compiler doesn't care.
Sorry to bring these up, it's been in the back of my mind for years but I never got around to checking up on them before.