glen herrmannsfeldt <
g...@ugcs.caltech.edu> wrote:
> For GET_ENVIRONMENT_VARIABLE, value, length, status, and trim_name
> are all optional arguments. At least for me, I would probably get
> out the manual (I have the PDF ready to look at) each time for
> some number of times.
>
> Do you know how TRIM_NAME works without looking it up?
I wasn't completely sure, but I checked and my guess was right. However,
and I think it a really important point rather than some nit, trim_name
is an arcane feature that almost nobody will never need to use. It is
there so that that arcane case can be handled when you really want it to
be. You can look it up in those arcane cases. (For those who might not
bother to look it up, trim_name is for the case where traling blanks in
an environment variable name are actually significant, which isn't going
to happen much.)
On the other hand, Qolin was talking about cases that are going to come
up all the time, and increasing over time. (Yes, I know I just implied
that it will start with always and then get more common, but I think
I'll leave it that way). Allocatable length character strings ought to
end up getting used darn near everywhere because they mostly act like
people intuitively expect character strings to act. Qolin was basicaly
pointing out exceptions to that "mostly".
> Well, the other possibility is to add a new intrinsis function.
That's got pretty much the same issue of remembering to use the right
one... and more so if there might be more than one argument of character
type. I don't see it as something that does very well at looking
forward.
I much better like the idea I mentioned of having it "just work". No
special attention required by the user. Unless you see some actual
reason why that can't be made to work, I see no point in comming up with
arcane hacks like essentially making two arguments or two intrinsics. If
it's just because you think a "clean" solution that involves a new
feature would be a harder sell than a hacked up one that uses only
existing features, I guess I just disagree. Might well be that none of
these would sell, but I'd think a clean solution would have better odds.
(It sure would with me).
> As a function return value, does its length naturally get used
> in assignment, with allocate on assignment?
I'll give the same answer I have given other people for other questions
relating to function returns and assignment in a much broader context:
If you have to put the words "function" and "assignment" in the same
question, then you are probably thinking of it all wrong. Functions have
pretty much nothing to do with assignment. Look at the definition of
assignment; you won't see anything about functions in it. And look at
the definition of a function reference; you won't see anything about
assignment in that.
Function references get used in expressions. Sometimes it is a trivial
expression consisting of the function reference as its only primary. But
it is still an expression. So you evaluate the expression using whatever
rules for expression evaluation apply. This has *NOTHING* to do with
whether or not the expression is used in an assignment. Yes, by the way,
an expression that consists of only a single primary has the same type
and type parameters as that primary.
Expressions get used in assignment statements (and other places).
Allocate-on-assignment has nothing to do with what might be inside of
the expression. It either happens or doesn't depending on the properties
of the variable and the expression result.
If you couldn't follow that, the short-form answer is "yes". But if you
need that short form, I'll continue to have to give you a fish every
meal. The real answer is to not think of functions and assignment as
having much to do with each other.
And, back to Qolin's question, this does imply that it is not an issue
for function returns - only for arguments.
> No comment on the OPTIONALLY_ALLOCATABLE dummy arguments and
> the IS_ALLOCATABLE function to test them?
Not really, because I didn't have much to say about them one way or
another without more thought than I had put into it. I sometimes (too
often) put my foot in my mouth by speaking up without thinking enough
first. But I do at least try to cut down on it.
Having thought about those questions at least a little more, though
certainly not yet enough, I'd say that they do seem like plausible
ideas. I had been thinking particularly about intrinsics. You don't need
things like that for intrinsics because you don't have to write the code
for intrinsics in Fortran. Intrinsics can sometimes do things that
user-written subroutines cannot.
But such an attribute and function might allow user-written procedures
to be written to act in the same kind of way.
I'm not sure there is as much need for it in user-written procedures.
The standard intrinsics have to cater to diverse environments, including
code written in different styles and different times. I'm not sure that
applies quite as much to user-written procedures. So that makes me
unsure of the priority of such a feature. But I can at least picture it
as plausible.