[J3] ALLOCATE with source-expr determining the array bound & resulting lower bound
Van Snyder
van.snyder at sbcglobal.net
Wed Dec 1 21:29:07 UTC 2021
On Wed, 2021-12-01 at 09:59 +0100, Tobias Burnus wrote:
> True - but in most cases, the lower bound of an expression is not
> needed.
>
> It is only required when referencing LBOUND and for whole arrays,
> where
> it matters for array-element / array-section (and LBOUND).
>
> But all those seem to be covered – except for ALLOCATE with source-
> expr,
> which just has "the bounds of source-expr determine the bounds of the
> array.":
I agree with Tobias that this is confusing.
15.3.3 describes the characteristics of the function result variable.
15.5.3 describes function reference, and refers to the characteristics
of the function result variable described in 15.3.3. One might expect
that all those characteristics apply to the result value. They
apparently all do apply -- except whether the result value is
allocatable. 15.3.3 also states that the shape is not a characteristic
of the function result if the result is allocatable or a pointer. If
the result has no shape, LBOUND cannot be applied. Except it is
apparent that the result value of a function whose result is a pointer,
is itself a pointer, so it has bounds.
8.5.3 has a nonnormative note that a function result value is not
allocatable. After comparing 15.3.3 and 15.5.3, one might wonder where
there is normative support for the note. I was not able to find it. If
there is no normative support, it needs to be provided. If there is
normative support, the note should refer to it, and it should be
explicit in 15.5.3.
If there is no normative support for the note in 8.5.3, there should be
an explicit decision whether the value of the result of executing a
function has all the characteristics of the result variable, or
"whether it is allocatable" is singled out for exclusion. I would
prefer that "whether it is allocatable" be included so that if one
wants to keep the result value for future use, one can use MOVE_AL:LOC
instead of copying the value. This might also simplify processors. With
the result value not being allocatable, either the result value
descriptor needs to be changed so that its lower bounds are 1 and its
upper bounds are SIZE, or LBOUND and UBOUND need to be especially aware
that their argument is the result value of a function whose result
variable is allocatable. It would also make the result values of
functions whose results are allocatable and pointers more similar.
It would also be useful to have an explicit discussion of the case
where the result variable is not allocatable or a pointer, but its
bounds are not necessarily 1.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20211201/d032c072/attachment.htm>
More information about the J3
mailing list