Re: Proper way to return a string
- From: Paul van Delst <Paul.vanDelst@xxxxxxxx>
- Date: Thu, 28 Dec 2006 12:33:55 -0500
Richard E Maine wrote:
Terence <tbwright@xxxxxxxxx> wrote:
For any string operation I always use a function call because this can
return an error code,
I've noticed that I usually disagree with almost every style preference
Terence expresses. If there is an exact opposite of his preference,
you'll usually be right in guessing that opposite to be my preference.
It applies here.
For me, returning an error code is a reason to avoid using a function.
For more anecdotal evidence of opposite behaviour, if I have a procedure in which an error is "detectable" (say, via STAT, IOSTAT, or simply checking the validity of input arguments) then I always do:
errStatus = MyFunc(inarg1,inarg2,...,outarg1,outarg2,....)
IF (errStatus /= SUCCESS) THEN
...handle error...
END IF
rather than,
call MySub(inarg1,inarg2,...,outarg1,outarg2,...,errStatus)
IF (errStatus /= SUCCESS) THEN
...handle error...
END IF
My reason for doing so is only because I find the function call form easier to parse when I'm looking at source code. I don't subscribe to the argument (no pun) that functions, in general, should not have side effects (that's how I interpret your comments so disabuse me of that if necessary). I fail to see the point in that sort of restriction purely (again, no pun) as a point of style. I have followed the more language/standard-oriented comments you and others have made for and against functions with side-effects in clf in the past and every time the topic has come up the thread result was effectively "let's agree to disagree".
cheers,
paulv
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
.
- Follow-Ups:
- Re: Proper way to return a string
- From: Richard E Maine
- Re: Proper way to return a string
- References:
- Proper way to return a string
- From: Jeremy
- Re: Proper way to return a string
- From: Steven G. Kargl
- Re: Proper way to return a string
- From: Gordon Sande
- Re: Proper way to return a string
- From: Steven G. Kargl
- Re: Proper way to return a string
- From: Terence
- Re: Proper way to return a string
- From: Richard E Maine
- Proper way to return a string
- Prev by Date: Re: dummy argument assumed-size
- Next by Date: Problem with my split routine I am not understanding
- Previous by thread: Re: Proper way to return a string
- Next by thread: Re: Proper way to return a string
- Index(es):
Relevant Pages
|