[J3] Should all intrinsic functions be simple?
Brad Richardson
everythingfunctional at protonmail.com
Tue Dec 19 16:04:20 UTC 2023
Hi all,
For F2023 we changed our blanket statement from:
All standard intrinsic functions are pure.
to
All standard intrinsic functions are simple.
At first glance this seemed reasonable, but on closer inspection it
seems several intrinsic functions are not conceptually simple. The
constraints for simple procedures:
Any procedure referenced in a simple subprogram shall be simple.
A simple subprogram shall not contain a designator of a variable that
is accessed by use or host association, unless the designator is part
of a specification inquiry (10.1.11) that is a constant expression.
A simple subprogram shall not contain a reference to a variable in a
common block.
Would seem to indicate that references to simple procedures with
identical arguments would be suitable candidates for common
subexpression elimination optimizations. However, that would not
necessarily be true for all of the intrinsic functions. Take the
following example:
cur_team = get_team()
...
change team (new_team)
cur_team = get_team()
...
end team
Clearly, it is intended that the two calls to get_team return different
results, so common subexpression elimination would not be valid here.
Also, conceptually, it would not be possible to implement this call in
a way that does "not contain a designator of a variable that is
accessed by use or host association" or "not contain a reference to a
variable in a common block" as it clearly must be accessing some global
state of the program.
Intrinsic functions which may be affected include:
* failed_images
* get_team
* image_index
* num_images
* stopped_images
* team_number
* this_image
I may have missed some. I think this is worth correcting. What do you
all think?
Regards,
Brad
More information about the J3
mailing list