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)
Path: h9ni34484pbe.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Dick Hendrickson <dick.hendrick...@att.net>
Newsgroups: comp.lang.fortran,comp.lang.pl1
Subject: Re: Array constructors and types
Date: Sat, 03 Mar 2012 06:59:58 -0600
Lines: 42
Message-ID: <9reiueFk60U1@mid.individual.net>
References: <1330137388.326978@athprx03> <9qr2b6F17uU1@mid.individual.net> <1kfzhvb.qqvjj91hb5j2aN%nospam@see.signature> <c5ab7192-eeed-4d8f-9a66-8cfeee6fb7a3@z31g2000vbt.googlegroups.com> <4F4C7E49.9010701@net-b.de> <7eaa5522-4633-4ca4-a51b-0f9424c7265d@k4g2000yqa.googlegroups.com> <4F4CB46F.2090905@net-b.de> <7e5a1d7c-7342-44d4-a666-818903e37f68@p12g2000yqe.googlegroups.com> <9r5fbnF4cvU1@mid.individual.net> <b5e3d78e-768c-42ae-9669-b487add2c5d5@ni10g2000pbc.googlegroups.com>
Mime-Version: 1.0
X-Trace: individual.net DwPdIDJHrp5trd6vm1pLcwQZ9TbudL75GmVpSft7j/lRRMsxLX
Cancel-Lock: sha1:8UfUUuFG8yMpdjODP4FzyPr9SIk=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0
In-Reply-To: <b5e3d78e-768c-42ae-9669-b487add2c5d5@ni10g2000pbc.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
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
>>>>> about.
>>
>>>> One clearly mixes different types: They all differ in the length-type
>>>> parameter.
>>
>>> 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.
Dick Hendrickson