| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Returned values |
While listening to John Gardeniers Pete heard:Returned values
G'day John
PC> Why not look around for a 2nd hand copy of Quick C 2.5, it runs
PC> on an XT and would be a step up from PCC
JG> Thanks for that, I'll keep my eyes open for it. One (of the
JG> many) reasons I still use PCC is that I generally have no way of
JG> knowing whether or not any given compiler will run on the XT.
Not many do now days but then again not many people use XT's either.
PC> I think defining FALSE to a non-zero value would be a bad habit
PC> to get into, it would be better to always assume FALSE to be
PC> zero.
JG> If a function succeeds I only need to know so but if a function
JG> fails I want to know why, without having to do anything else to
JG> find out, hence I use non-zero for false/fail/no, etc. Probably
JG> more for consistancy than anything else I use zero for true,
JG> even if the result is purely true or false. I only realised I
JG> was doing this after you questioned it. At first I thought it
JG> must simply be a bad habit but now believe that it's the best
JG> way to do it. You will notice that DOS (command line) does the
JG> same thing. Successful completion of a DOS funtion will return
JG> an errorlevel of zero.
I think your confusing flag values with boolean values here,
Errorlevels as the name implies means a level of errors, a return of 0
means no errors occurred.
JG> One thing in favor of having TRUE=0 is that on a no error
JG> completion of a function you can simply "fall through" at the
PC> Your relying on your compiler to clear AX for you on returning
PC> from a function, you must also have the warnings threshhold set
PC> low as my compiler (QC) generates a warning if i forget to add a
PC> 'return n;' in functions that return a value.
JG> After reading this I had a good look at some of my code and
JG> found that whenever I used the value returned by a routine I
JG> *did* use an explicit return n;, I obviously do it out of habit.
JG> PCC has extremely limited error checking, so won't give a
JG> warning if the return is left out. One side benefit of this is
JG> that you tend to become a better programmer because you have to
JG> to do it all yourself instead of waiting for the compiler to
JG> pull you into line. i.e. With too much error checking by the
JG> compiler it's far too easy to become sloppy and careless.
I don't think there's a programmer alive that doesn't overlook
something every now and then and if your compiler can point the error
out thats one less bug to try and find. IMO smart compilers don't make
sloppy programmers as having your oversights pointed out to you makes
it more likely that you'll remember the error and not do it next time.
Pete.
EMail:pcollis{at}ozemail.com.au
--- OMX/Blue Wave v2.12
* Origin: Gates of Hell (3:713/914.16)SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 430 808 809 932 934 SEEN-BY: 712/508 515 713/111 317 601 611 615 618 700 826 888 914 714/906 SEEN-BY: 800/1 @PATH: 713/888 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.