TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Joshua Marshall
from: John Gardeniers
date: 1996-05-04 14:56:32
subject: Value returned fom a function

-=> On 22 Apr 96  16:36:48 <=-
-=> Joshua Marshall was heard to tell John Gardeniers <=-

        Hello Joshua,


 JG>        I use PCC and to keep the speed up, as much as practical (I use
 JG> an XT to do my programming), I avoid header files.

 JM> You are truly a sick man.

         It's cheaper than whips and chains.

 JM> The general idea of using zero for FALSE and non-zero for TRUE is that
 JM> you can do things like this:
 JM> is_working=TRUE;

        You can still do that if TRUE=0.

 JM> Also if a function returns either TRUE or FALSE you can have it in a
 JM> conditional the same way, eg:
 JM> if (ok_to_save())
 JM> {
 JM> save_it();
 JM> }

        I would use:

        if(!ok_to save())
                save_it();

        I will admit that my normal use of "if (!function())" to test for
success does read a bit reversed but then again have a look at what we *do*
get used to doing!

 JM> When you know that the variable or function is boolean it makes the
 JM> code easier to read and understand.
 JM> For instance, my first example with your definitions:

 JM> is_working=TRUE;

 JM> if (is_working==TRUE)
 JM> {
 JM> blah;
 JM> }

 JM> Isn't quite as easy to read for debugging purposes.

        What about this:

        if(function())
        {
                switch(is_working())
                {
                        case 1:
                        {
                                do error stuff 1;
                                break;
                        }

                        case 2:
                        {
                                do error stuff 2;
                                break;
                        }

                        case n:
                        {
                                do error stuff n;
                                break;
                        }

                        default:
                        {
                                do unrecognised error stuff;
                                break;
                        }
                }
        }

        fell through so must have succeeded;

 JM> Member TEAM AMIGA                    AmigaNet 41:400/452.35
                 ^^^^^
        And you said *I* was a sick man!!! :-)

                John

... Anything that works can't be ALL bad.
---
* 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™.