Re: Proper way to return a string
- From: nospam@xxxxxxxxxxxxx (Richard E Maine)
- Date: Thu, 28 Dec 2006 08:53:27 -0800
e p chandler <epc8@xxxxxxxx> wrote:
As I understand it, a character(*) function returns a character
variable whose length is fixed by its caller.
Correct. Returning variable-length character function results, where the
length is computed within the function, is *VERY* tricky. It is
impossible in f77. (Taking the same length computation and duplicating
it outside of the fucntion is "cheating" - that no longer counts as
doing the computation within the function). In f90, you can sometimes do
it with specification expressions. In f90, specification expressions can
do much more (notably because they can reference user-written pure
functions), but they can be very messy and sometimes inefficient.
Not until f2003, with allocatable character length, can you finally do
general cases "cleanly". (And I don't off-hand know of any compilers
that yet implement allocatable character length, though it is possible
that the newest versions of some compilers might be, at least soon).
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- 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: Ron Shepard
- Re: Proper way to return a string
- From: e p chandler
- Proper way to return a string
- Prev by Date: Re: internal I/O to substring
- Next by Date: Re: Proper way to return a string
- Previous by thread: Re: Proper way to return a string
- Next by thread: Re: Proper way to return a string
- Index(es):
Relevant Pages
|