Assumed character length functions - PR15326

Paul Thomas Paul.Thomas@jet.efda.org
Fri Jun 10 16:09:00 GMT 2005


Tobi,

After we discussed the character PRs a couple of months back, I briefly
toyed with the idea of passing characters as structures in all
circumstances.  However, the job of putting this into action was so huge
that I determined that I did not have the time or the inclination to try it.

I think that (ii) will be simpler than your suggestion but I will give some
thought to the matter before concluding that.

Thanks

Paul T

-----Original Message-----
From: Tobias.Schlueter@physik.uni-muenchen.de
[mailto:Tobias.Schlueter@physik.uni-muenchen.de]
Sent: 10 June 2005 16:52
To: Thomas, Paul
Cc: 'Tobias Schlüter'; 'fortran@gcc.gnu.org'
Subject: Re: Assumed character length functions - PR15326


Quoting Paul Thomas <Paul.Thomas@jet.efda.org>:
> There are three viable solutions, as far as I can tell: (i) Since the
> character string is passed by reference, the function could return the
> string length; (ii) The string length could be passed by reference instead
> of by value, as the second argument; or (iii) it could be passed by
> reference as another hidden argument.

There's a third option: make the function type a structure describing the
string, i.e. something like
struct char_with_len {
  char * string;
  int len;
}
and then do away with the hidden arguments.  This should even work for
functions
with ENTRYs, as the allowed combinations of types are restricted enough,
unfortunately I can't say for sure because I don't have the standard at
hand.

> (ii) and (iii) have the advantage of being relatively simple to implement.
I
> prefer (ii) because it is slightly more elegant. I do not think that it
has
> any unwanted side-effects and is compatible with every permutation of
> function invocation that I can think of.
>
> Does anybody have an opinion on this? OK to implement (ii)?

I believe (ii) would work as well, I don't think it would be necessarily
easier
than my suggestion, though.

- Tobi




More information about the Fortran mailing list