Re: bug in g95 with character arrays?



Richard Maine wrote:
glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

My first thought is that it should work for a DATA statement,
but now I am not even sure about that.

Depends what your referent is for "it". If you are referring to an array
constructor whose elements have different character lengths, then the
answer is twofold

1. Such array constructors are not allowed in the first place. Period.
Context is irrelevant.

2. Data statement values are required to be scalar anyway, so they can't
be array constructors, regardless of whether the array constructor is
valid or not.

Yes, but a DATA statement can initialize an array. As you say, I
look at the implementation too early. In any case, the actual
data has to be stored somewhere.

If you are talking about character values in data statements having
different character length, then

1. There is no relationship among the different values in a data
statement, so there is no particular restriction on the
non-relationship. Each value is related only to its corresponding
data-statement-object.

As one might also think for an array PARAMETER.

2. Intrinsic conversion is allowed, so yes, that allows the character
lengths in the values to be diferent from the character length of the
data-statement object. That's also true of the other syntax of
initialization, by the way. The restriction in question relates only to
array constructors, independent of context. The array constructor
doesn't have to agree in character length with the variable being
initialized; it just has to be a valid array constructor in the first
place, with *SOME* well-defined length.

One might think that PARAMETER was different, but it
seems that it isn't.

One wouldn't think that if one realized that an array constructor is an
array constructor and is independent of context, like pretty much
everything else in expressions. *SURELY* you are aware of that kind of
issue in regards to precision; in fact, it is practically the same
issue, insomuch as kind and length are both type parameters.

DEC had PARAMETER in some of the Fortran 66 compilers many years
ago. It was a great improvement because it allowed, for example,
symbolic names for array dimensions. Variables weren't allowed,
even constant expressions weren't, but PARAMETERs were.
(And PARAMETERS were even allowed constant expressions.)

One result is that I tend to think of PARAMETER as
different from assignment. The problem of precision of REAL
variables and PARAMETER was discussed not so long ago.

Mixed mode expressions are one of the conveniences of Fortran,
not having to do explicit conversions. Good or bad, that
extends to single precision constants assigned to double
precision variables. But PARAMETER is different.

At least I still think of PARAMETER as a named constant.
Unlike the case of mixed mode expressions, there doesn't
seem to be as good a reason to allow (at least without
a warning) PARAMETERs with the wrong type.

Even so, assigning the type (and length) of an array
constructor on the first element does seem strange.

-- glen

.



Relevant Pages

  • Re: Need basic help....
    ... Create a new object, with an empty character, and also a new ... constructor is. ... private char theChar; ...
    (comp.lang.java.help)
  • Re: Formatting a string in Java
    ... and I can put any fill character in there I like: ... Strings = new MyString('0', length).get; ... implements CharSequence and has a "filler" constructor, ...
    (comp.lang.java.programmer)
  • Re: Need basic help....
    ... Create a new object, with an empty character, and also a new ... constructor is. ... public void setFromKeyboard() {... ... public char get{... ...
    (comp.lang.java.help)