Re: Proper way to return a string
- From: kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx (Steven G. Kargl)
- Date: Wed, 27 Dec 2006 19:21:38 +0000 (UTC)
In article <slrnep5g8k.3020.Jeremy@xxxxxxxxxxxxxxxxxxx>,
Jeremy <my-first-name@xxxxxxxxxx> writes:
I am wrapping (because I cannot find it already done, if you know of one
that exists let me know!) libpq for PostgreSQL database access. A
function, PQresStatus returns a string version of the result status. In
returning this to Fortran, can I return it from a function call? Should
I? Should I use a subroutine, I know how to easily deal with giving
string information back that way.
I guess I am still trying to understand when I should use a function
and when I should use a subroutine with inout/out parameters.
The following is my opinion. I'm sure others here will prefer
a different set of rules.
For numeric and logical types, if the routine computes a *single*
result, then I use a function. The function can take zero or
more arguments. If more than one result is to be returned, then
I use a subroutine. The distinction gets blurred when one starts
to consider array operations where the result is an array. Is the
array a single result or is it a collection several individual
elements?
For strings, I always use subroutines. I don't remember why I
developed that habit. It is just something I do.
There are, of course, exceptions to the rules. Here, one should
provide good comments, so the exceptions are well understood.
In the end, one should develop a style and stick with it.
--
Steve
http://troutmask.apl.washington.edu/~kargl/
.
- Follow-Ups:
- Re: Proper way to return a string
- From: Gordon Sande
- Re: Proper way to return a string
- References:
- Proper way to return a string
- From: Jeremy
- Proper way to return a string
- Prev by Date: Re: READ and delimited format
- Next by Date: Re: Proper way to return a string
- Previous by thread: Proper way to return a string
- Next by thread: Re: Proper way to return a string
- Index(es):
Relevant Pages
|
|