[J3] Consideration of Paper 18-242 at Meeting 218 (Was: 18-242)
Vipul Parekh
parekhvs at gmail.com
Mon Dec 3 23:11:53 EST 2018
On Mon, Dec 3, 2018 at 3:26 PM Van Snyder via J3
<j3 at mailman.j3-fortran.org> wrote:
>
> On Mon, 2018-12-03 at 15:12 -0500, Vipul Parekh via J3 wrote:
> > do ( integer(8) :: i = n:m ) !<-- NOTE the parenthesis around the loop
> > header and the colon in control spec as in n:m instead of n,m
> > ! object i is now a construct entity
> > if (a(i) < 0) exit
> > end do
>
> The colon in the loop control in DO CONCURRENT (and FORALL) was intended
> to emphasize that iterations are not in any particular order.
>
> The comma in the loop control for the current (and proposed) DO
> construct are intended to emphasize that the iterations are in the order
> of the sign of the stride expression.
>
>
I couldn't find a reference to such an emphasis in the text of the
standard, can someone please point me to it?
Regardless, in the context of the DO construct. any emphasis attempted
to be conveyed by the colon versus a comma appears superfluous
considering the monstrosity of the keyword CONCURRENT and what it
implies about a lack of any particular order in the execution of the
loop. I presume it was retained for consistency with FORALL
construct. But the value of any additional emphasis with colon looks
questionable to me, does anyone have any information that points
otherwise?
Separately, a loop header such as
do integer(kind=IK) :: i = n, m
..
end do
might look alright to some coders in terms of syntax, but I suspect it
will come across as somewhat odd to others. Now if I recall
correctly, the standard allows an optional comma after DO as in
do, i = 1, 20
but I have never seen it get used, so I won't comment on it here.
I also wonder if implementations would have concerns with parsing
Van's proposed syntax as in <do integer :: i = 1, m>.
Considering the existing DO CONCURRENT facility in Fortran and what
many coders will be familiar with in other languages, I think the
presence of enclosing parenthesis will be preferable. I would also
suggest allowing commas in addition to colons in DO CONCURRENT now
that FORALL is obsolescent. New coders might find it easier to
understand the loop-variable inside the parenthesis is a construct
entity, whether it be in DO or DO CONCURRENT or io-implied-do or
ac-implied-do or data-implied-do e.g.,.
do ( integer(kind=IK) :: i = n, m ) !<-- Suggested
..
do concurrent ( integer(int64) :: i = 1, m ) !<-- Suggested - allow
commas in control section in addition to colon; concurrent keyword
*sufficiently* conveys lack of order in execution
..
data ( a(I), integer :: I = 1, 10) / 10*1.0 / !<-- Allowed already
..
y = [( 42+k, integer :: k = 1, size(y) )] !<-- Allowed already
..
write ( lun, * ) ( x(i), integer :: i=n, m ) !<-- Proposed in 18-242
Regards,
Vipul
More information about the J3
mailing list