Re: Proper way to return a string



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
.



Relevant Pages

  • Re: Proper way to return a string
    ... I've noticed that I usually disagree with almost every style preference ... If there is an exact opposite of his preference, ... returning an error code is a reason to avoid using a function. ... last keystroke input, which allows signalling of function keys, pad ...
    (comp.lang.fortran)
  • Re: Proper way to return a string
    ... I've noticed that I usually disagree with almost every style preference ... If there is an exact opposite of his preference, ... returning an error code is a reason to avoid using a function. ... I do have several basic string functions because they ...
    (comp.lang.fortran)
  • Re: Xahs Edu Corner: Tech Geekers and their Style
    ... old dog new tricks" when in fact my experience is the opposite, that the younger guys resist change the most and want to maintain the status quo. ... On the other hand, I don't appreciate being told that my personal preference is wrong, that my preference had been discussed before and that it was determined that my preference was decidedly odd. ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: A Manual of Practical Reason
    ... :My preference, in general, is that all this happen without my getting ... :angry or getting anyone angry at me. ... :shares that preference. ... Many people prefer the opposite I found out. ...
    (sci.logic)