Skip to content

Specify module entities that are accessible by default (not necessarily all public) #216

Open
@Jellby

Description

@Jellby

Module variables and procedures can be private or public. As far as I understand, private entities simply cannot be accessed from the outside at all (by other program units useing the module), while all public entities are immediately accessible by anyone who uses the module without (only).

For convenience, and to help structure the entities in a module, it would be useful to have the possibility of specifying entities that can be accessed, but which must be explicitly specified with only. For example:

module foo
  integer, parameter, private :: fortytwo
  integer, public :: const = fortytwo, version = 3
  default :: const ! suggested syntax
end module foo

With this, use foo would get access to const only, while use foo, only: const, version would get access to both variables.

If an empty default list is specified (maybe with default none), it would enforce the use of only in any use attempt for the module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Clause 14Standard Clause 14: Program units

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions