Showing changes from revision #2 to #3:
Added | Removed | Changed
Proposal: Support a CONSTANT attribute for non-modifiable data, or expand the use of PROTECTED to provide the same functionality.
A constant value can be represented by a PARAMETER, but you cant point to parameters. F2003/F2008 have a protected attribute which can provide a context-dependent constant attribute, which is similar to the way ‘const’ is used in C.
A pointer to constant data is probably the best example, It requires constant data to point to (i.e. a CONSTANT variable and not a parameter) and a way to indicate the writable status of pointee data in a dummy argument. With pointers INTENT only applies to the pointer itself. There is no way to indicate the constant status of the data.
In C, you can have a const pointer to modificable modifiable data, or a non-const pointer to const data, or a const pointer to const data. INTENT was orignally originally not supported for pointers due to the ambiguity of the attribute belonging to the pointer or the pointee, but there should be a way to support both.
This feature would also allow tables data to be initialized with DATA statements, flagged as constant, and placed in read-only memory at run-time.
PROTECTED may be a attribute for non-modifiable data. In C headers, const is used to indicate whether data can be modified from a given scope, although the same data may not be constant from another scope. Therefore, PROTECTED is a better match for C behavior. Data objects can still be placed in read-only memory if they are PROTECTED in all scopes. However, this idea may conflict with the existing use of PROTECTED.