Message from discussion Array constructors and types
Received: by 10.68.189.197 with SMTP id gk5mr7378820pbc.1.1330779600383;
Sat, 03 Mar 2012 05:00:00 -0800 (PST)
From: Dick Hendrickson <dick.hendrick...@att.net>
Subject: Re: Array constructors and types
Date: Sat, 03 Mar 2012 06:59:58 -0600
References: <1330137388.326978@athprx03> <9qr2b6F17uU1@mid.individual.net> <1kfzhvb.qqvjj91hb5j2aNfirstname.lastname@example.org> <email@example.com> <4F4C7E49.firstname.lastname@example.org> <email@example.com> <4F4CB46F.firstname.lastname@example.org> <email@example.com> <9r5fbnF4cvU1@mid.individual.net> <firstname.lastname@example.org>
X-Trace: individual.net DwPdIDJHrp5trd6vm1pLcwQZ9TbudL75GmVpSft7j/lRRMsxLX
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 3/2/12 1:19 AM, Robin Vowels wrote:
> On Feb 29, 1:03 pm, Dick Hendrickson<dick.hendrick...@att.net> wrote:
>> On 2/28/12 8:08 AM, Robin Vowels wrote:
>>> In the case of Fortran, it's simply resolved by choosing the longest
>>> length of the elements in the constructor list.
>>> In PL/I, the problem doesn't arise, because elements in a
>>> character array are not required to have the same length.
>>> (See the attribute VARYING in the PL/I example that I gave earlier.)
>>>>> The constructor list is clearly an array of characters.
>>>>> It's not even a mixture of types, which is what others were worring
>>>> One clearly mixes different types: They all differ in the length-type
>>> As I said before, choose the longest length. Then nothing is lost.
>> There are two problems with this.
>> One is practical, given
>> [ ( repeat( 'x', int_func(i) ) , i = 1,N) ]
>> how do you find, in a reasonably efficient manner, the longest length?
>> There seem to be only two solutions. One is to evaluate int_func(i) N
>> different times, save the results, and (trivially) compute the maximum.
>> Then use the saved list of int_func(i) to do the repeat function and
>> append enough blanks. Clearly, the Fortran side-effects rules don't
>> allow you to evaluate int_func(i) from 1 to N twice. The other is to
>> just march through the list and go back and add blanks each time a
>> larger length is encountered. Since N can be large, neither was
>> believed to be practical.
> Think of it as an assignmenet to a character array.
> It's no more difficult.
No, you're missing my point. In a character array assignment the
element size is known and each individual value can be converted to the
right length one at a time. There are no surprises; no need to go back
and fix something or to look ahead to see what the "real" length is.