F From:	SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com" 26-MAY-1993 08:27:27.14 To:	EVERHART CC:	+ Subj:	Re: "optional" efn and iosb arguments   O X-Listname: "VMS Internals, MACRO, & BLISS Discussions" <MACRO32@WKUVX1.BITNET>  Warnings-To: <> - Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com * Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com X-Newsgroups: vmsnet.internals. Subject: Re: "optional" efn and iosb arguments1 Message-Id: <1993May26.201229.2296@zl2tnm.gen.nz>  From: don@zl2tnm.gen.nz + Reply-To: MACRO32%WKUVX1.BITNET@uu7.psi.com  Date: 26 May 93 20:12:29 +1300 Distribution: world  Organization: The Wolery	 Lines: 95  To: MACRO32@WKUVX1.BITNET  X-Gateway-Source-Info: USENET   E In article <1993May25.085020.2058@cmkrnl.com>, jeh@cmkrnl.com writes: M > In article <1993May25.201653.2295@zl2tnm.gen.nz>, don@zl2tnm.gen.nz writes: J >>         IF YOU DO NOT SPECIFY AN IOSB [on $QIOW] YOU DO NOT KNOW IF THE6 >>         I/O HAS COMPLETED SUCCESSFULLY (OR AT ALL).M > That depends.  If your code uses NO asynchronous operations then it MUST be I > your $QIOW completion that set the flag, since there won't be any other 7 > $QIOW's or other event-flag-setting requests pending.   I Can you *absolutely* *guarantee* that the code (a) won't be run with some G hack or other setting EFNs in exec mode, and (b) that the code won't be I lifted out and used somewhere where there are asynchronous operations? If I not, put the IOSB in and check its status *now* and save yourself several  kinds of grief later.   A Fine for baby programs.  But even baby programs grow up to be big H programs sometimes.  That unprotected $QIOW can leap out of the woodwork+ and bite you (particularly if it's a read).   L >>         There are various bits of code around that do things in exec modeL >>         independently of the rest of the process that may set event flags$ >>         when you least expect it.K > I don't think that anything in RMS runs "independently of the rest of the P > process" unless you've asked it to via the ASY option.  Even when it does run,  H I was talking about some of the hacks that float about to do things likeH update prompts, change window titles on DECwindows screens & so-on.  OK,- they're not standard VMS, but why take risks?   I > a good idea!  But if you have no "no-wait" system service calls you can N > get away without them.  Provided you don't care about I/O completion status.  I You _should_ care about completetion status.  Not caring about completion E status is generally bad programming, in all but a very tiny number of  cases.  C Personally, if I'm writing stuff that uses $QIO[W] and friends that G doesn't use asynch calls, I just keep one iosb around and re-use it.  I I also make a habit if checking the IOSB.  Hell, it's usually only one more  line of code (even in MACRO!).  I > When the manual says "optional argument" it means "the service will not P > consider the arguments invalid if they are 0, passed by value".  By that test,C > efn and iosb really are "optional" for $QIOW.  And even for $QIO.   E That _wasn't_ the point.  When you depend on software to be reliable, " such hair-splitting is irrelevant.  $ Henry Spencer says it better than I:  6      The Ten Commandments for C Programmers (Annotated"                           Edition)  $                        Henry Spencer   [...]   < 6    If a function be advertised to return an error code  in<      the  event  of  difficulties, thou shalt check for that<      code, yea, even though the checks triple  the  size  of<      thy  code  and produce aches in thy typing fingers, for<      if thou thinkest ``it cannot happen to me'',  the  gods0      shall surely punish thee for thy arrogance.2                All true believers doth wish for  a2                better   error-handling  mechanism,2                for explicit checks of return codes2                are tiresome in the extreme and the2                temptation to omit them  is  great.2                But   until   the  far-off  day  of2                deliverance cometh, one  must  walk2                the  long  and  winding  road  with2                patience and care, for thy  Vendor,2                thy   Machine,   and  thy  Software2                delight  in  surprises  and   think2                nothing  of  producing subtly mean-2                ingless results on the  day  before2                thy Thesis Oral or thy Big Pitch To                The Client.2                Occasionally, as with the  ferror()2                feature of stdio, it is possible to2                defer error checking until the  end2                when  a  cumulative  result  can be2                tested, and  this  often  produceth2                code  which is shorter and clearer.2                Also, even the most  zealous  beli-2                ever should exercise some judgement2                when dealing with  functions  whose2                failure is totally uninteresting...2                but beware, for the cast to void is2                a  two-edged  sword  that  sheddeth/                thine own blood without remorse.    'nuff said.  8-)  O Don Stokes, CSC Network Manager, Victoria University of Wellington, New Zealand O Ph+64 4 495-5052  Fax+64 4 471-5386  Work:don@vuw.ac.nz  Home:don@zl2tnm.gen.nz 