To: J3 J3/14-244
From: Van Snyder
Subject: Subobjects of parameters and constants
Date: 2014 October 03
References: 14-007r2, 14-240
1. Introduction
===============
In
type :: T
integer :: C
end type T
type(t), parameter :: V = T(41)
1 v%c = 42
it's not obvious why statement 1 is prohibited, other than that no
interpretation is established. v%c is not a variable according to
subclause 1.3.156, but it's also not a constant.
The problem is that subclause 5.3.13 doesn't say that a subobject of an
object that has the PARAMETER attribute also has the PARAMETER
attribute, 2.4.3.2.3p1 doesn't say that a subobject of a constant is
a constant, and 6.3p1 says a named constant has a name, not a
designator, whereupon v%c is not a named constant (and therefore not
a constant, since it's also not a literal constant).
{Should this be part of the interpretation in 14-240?}
2. Edits
========
[37:23 2.4.3.2.3p1] Insert "is a constant that" after "constant".
[104:7+ C551+] Insert a paragraph:
"A subobject of an object that has the PARAMETER attribute also has the
PARAMETER attribute." {Compare to 5.3.10p6.}
[121:14 C601] Delete the now-redundant "or a subobject of a constant"
because a subobject of a constant is now a constant."
[122:3-4 6.3p1] Replace "A named constant... attribute (5.3.13, 5.4.11)"
with "A designator for an object with the PARAMETER attribute (5.3.13,
5.4.11) is a named constant".
{We don't want "A named constant has a designator that is a constant
expression and for which the first has the PARAMETER
attribute" because that would exclude things like A(I), where A is a
parameter and I is a variable, from the "constant" catagory -- there is
a difference between "constant" and "constant expression." If we ever
create things that quack like components but are parameters, the
proposed wording still works, but the alternative warned here does not,
i.e., V%C, where V is a variable and C is a "component" that has the
PARAMETER attribute ought to be a constant.}
[154:10 7.1.11p2(1)] Delete the now-redundant "or subobject of a
constant" because a subobject of a constant is now a constant.
[155:20 7.1.12p1(1)] Delete the now-redundant "or subobject of a
constant" because a subobject of a constant is now a constant.
{We don't need to worry in 7.1.12p1(1) about things like A(I), where A
is a parameter and I is a variable, because 7.1.12p2 excludes this case
from the "constant expression" category.}