TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Peter Collis
from: John Gardeniers
date: 1996-05-04 14:37:36
subject: Returned values

-=> On 22 Apr 96  13:23:12 <=-
-=> Peter Collis was heard to tell John Gardeniers <=-

        Hi Peter,

 PC> Why not look around for a 2nd hand copy of Quick C 2.5, it runs on an
 PC> XT and would be a step up from PCC

        Thanks for that, I'll keep my eyes open for it.  One (of the many)
reasons I still use PCC is that I generally have no way of knowing whether
or not any given compiler will run on the XT.

 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.

        If a function succeeds I only need to know so but if a function
fails I want to know why, without having to do anything else to find out,
hence I use non-zero for false/fail/no, etc.  Probably more for consistancy
than anything else I use zero for true, even if the result is purely true
or false.  I only realised I was doing this after you questioned it.  At
first I thought it must simply be a bad habit but now believe that it's the
best way to do it.  You will notice that DOS (command line) does the same
thing.  Successful completion of a DOS funtion will return an errorlevel of
zero.

 JG> One thing in favour 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 from a
 PC> function, you must also have the warnings threshhold set low as my
 PC> compiler (QC) generates a warning if i forget to add a 'return n;' in
 PC> functions that return a value.

        After reading this I had a good look at some of my code and found
that whenever I used the value returned by a routine I *did* use an
explicit return n;, I obviously do it out of habit.  PCC has extremely
limited error checking, so won't give a warning if the return is left out.
One side benefit of this is that you tend to become a better programmer
because you have to to do it all yourself instead of waiting for the
compiler to pull you into line.  i.e.  With too much error checking by the
compiler it's far too easy to become sloppy and careless.

                John

... C program, C program run, C program crash, C programmer cry.
---
* Origin: Melbourne PC User Group +61-3-9699-6788 (3:632/309)
SEEN-BY: 3/103 50/99 620/243 623/630 632/50 107 108 309 348 360 371 504 525
SEEN-BY: 632/530 533 562 633/371 634/388 396 635/301 502 503 506 544 639/252
SEEN-BY: 711/401 409 410 413 430 808 809 932 934 712/515 713/888 714/906
SEEN-BY: 800/1
@PATH: 632/309 107 635/503 50/99 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™.