James Giles writes:
> > [...] Not allowing character variables to
> > ALLOCATABLE with respect to their length is the worst of it.
> > I guess this is, at least partly, addressed in the current proposed
> > standard.
>
> Having just said that (based on vaguely remembered discussions
> in the newsgroup) I can't actually find the feature in the proposed
> document. Did I misremember, or is there somewhere in the
> document I need to look?
See 4.2, "Type parameters". Deferred type parameters is what you
are looking for. They aren't specific to character type, which
is why you won't find them there.
On the original question, I think that strings aren't specified as
arrays because it doesn't make sense to. A string is a single thing
that is more than just a sequence of characters. My last name is
"Maine"; it isn't an array of 5 characters. It makes no more sense to
define my last name as an array of 5 characters than it does to define
a real as an array of 32 bits. In both cases, the implementation is
likely to look like that, and in both cases there are times when you
might want to look at the parts. But a real has properties that are
fundamental to its being a real and that aren't captured by describing
it as an array of bits. Likewise a string has properties that aren't
captured by expression as an array of characters. For example, if I
test
string_1 < string_2
I want a single, scalar result that depends on the whole strings.
I don't want an array of results, one for each element. If I wanted
something like an array of results, then I probably didn't want
these things thought of as strings in the first place - I'd have
wanted them as an array of characters (which you can do).
I think that it is a mistake to view a string as just an array
of characters. That may be what an implementation looks
like, but one shouldn't confuse implementation with meaning;
the meanings are different. I think that a lot of people get
confused here by thinking that whatever C does is inherently
gospel. C tends to do pretty poorly at separating concepts
from implementations in this and several other areas.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|