PR fortran/19269 (partial fix): Lengths of reshaped arrays

Richard E Maine Richard.Maine@nasa.gov
Tue Sep 6 18:13:00 GMT 2005


On Sep 6, 2005, at 10:37 AM, Paul Brook wrote:

>> (b) the character length of the array is the maximum of every 
>> individual
>> element.
>
> I'm not sure about this because...
>
>> +   (/ 'a', 'bee', 'cedar', 'dog' /)
>
> This is illegal.
....
> Is this an extension we provide that I've forgotten about?

And if you do provide an extension like that, I'd be more than mildly 
curious as to whether it actually works in *ALL* the peculiar edge 
cases. J3 spent a huge amount of time trying to come up with a 
specification that was both 100% correct and was reasonably 
implementable. There were several attempts, but queer enough edge cases 
turned up to kill them all. I don't have a handy list of test cases, 
but some of the features of the nastiest ones were.

1. Zero-size arrays. Hard to pick the largest size of an empty set. In 
simple cases, it can be extrapolated from non-zero-size cases, but not 
always.

2. Lengths that can't be determined at compile time, perhaps because 
calls to user-written functions were involved in the length.

The nastiest cases sometimes combined both properties. You couldn't 
compute the length at compile time because of a function call. And you 
couldn't even compute it at run time because of zero-trip implied DO 
loop kept there from being any elements. You aren't free to go invoking 
user-defined functions for an element that isn't there.

3. You could also get into cases that were theoretically doable, but 
required the implementation to do something like make a linked list of 
temporary strings. Basically, if the length is given by a user-written 
function, you might need to evaluate every element of the array before 
you can tell which element is longest. And you can't "cheat" by 
evaluating them twice because that would call the functions twice 
(imagine functions that involved random number generators and thus 
didn't return the same values when called again). So you sort of have 
to store all the elements temporarily. Yukk.

Maybe you found a "magic" trick that a lot of other smart people 
couldn't find with lots of work. Could be... but my guess would be 
otherwise.

I think it more likely that you have some limitations on where it 
works. That can be fine.... but in that case it would be good to have a 
precise statement of what the limitations of the feature are rather 
than stating that it works in all cases and waiting for the bug 
reports.

-- 
Richard Maine                |  Good judgment comes from experience;
Richard.Maine@nasa.gov       |  experience comes from bad judgment.
                             |        -- Mark Twain



More information about the Fortran mailing list