08-249
To: J3
From: Michael Ingrassia
Subject: Public Comment J32035
Date: 2008 July 08
----------------------------------------------------------------------
Commenter's Subject was "IMPURE ELEMENTALs"
I don't see the value in having IMPURE ELEMENTAL procedures.
There are no examples in the draft standard and the only
example in the document describing new features can be
rewritten without the procedure being ELEMENTAL at all.
The example in the document is:
impure elemental function accumulate (a,sum)
real :: accumulate
real, intent(in) :: a
real, intent(inout) :: sum
sum = sum + a
accumulate = sum
end function accumulate
Where the call is:
real a(n), sum
:
sum = 0.0
a = accumulate (a,sum)
This seems simple enough. But suppose SUM was also declared
to be an array. The procedure would no longer "accumulate".
Nor would it generate any error messages or warnings. An
elemental is simply not a good way of accompishing such things
in the first place. You're trying to graft inappropriate
functionality in a place it doesn't fit well.
Now, if the procedure were declared:
function accumulate (a,s)
real, intent(inout) :: s
real, intent(in) :: a(:)
real :: accumulate(size(a))
s = sum(a)
accumulate = s
end function accumulate
The caller could be the same. The SUM argument could even be made
optional - it is certainly required to remain a scalar.
----------------------------------------------------------------------