(j3.2006) Is this a constant expression?
Van Snyder
van.snyder
Sat Nov 12 18:14:53 EST 2011
Given
type :: T(N)
integer, length=n
character(len=n) :: C
integer :: I
end type T
is
type(t(3)), parameter :: P = t(3)('abc',42)
a valid named constant declaration?
Is the situation different if N is a kind parameter?
There's nothing in 7.1.12 that says t(3)('abc',42) isn't a constant
expression.
Not being a Fortran compiler developer, I don't know how objects of
types with length parameters are to be implemented. I have heard
remarks that they have to be handled as if they had allocatable
components. If that's so, allowing this constant expression seems to be
a bit of a burden.
On the other hand, if the components' values are within the object
instead of the heap (or stack) with, offsets (or pointers) to components
that follow ones whose sizes depend upon length parameters either stored
in hidden components such as "integer :: _offset_to_I", or computed from
the type parameters at each reference to such components, maybe allowing
t(3)('abc',42) as a constant expression is implementable.
More information about the J3
mailing list