Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulate global constants in namespace of surrounding type #448

Open
mx990 opened this issue Sep 3, 2024 · 1 comment
Open

Encapsulate global constants in namespace of surrounding type #448

mx990 opened this issue Sep 3, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@mx990
Copy link
Member

mx990 commented Sep 3, 2024

This is necessary to avoid name collisions or ambiguity between constants declared in the same package but in distinct files, as well as with variables declared in the current scope. It also puts an end to the special treatment of global constants being available directly outside of the scope of their enclosing type.

Add a new GLOBALCONSTANTS syntax element to represent the enclosing type:

PACKAGE forte::core;

GLOBALCONSTANTS Math
    VAR_GLOBAL CONSTANT
        PI : REAL := 3.14159;
    END_VAR
END_GLOBALCONSTANTS

and refer to constants using either:

  • the full-qualified name forte::core::Math::PI,
  • the semi-qualified name Math::PI with an import for forte::core::Math (preferred),
  • the unqualified name PI with an import for forte::core::Math::PI or forte::core::Math::* (discouraged).
@mx990 mx990 self-assigned this Sep 3, 2024
@mx990 mx990 added the enhancement New feature or request label Sep 3, 2024
@azoitl
Copy link
Contributor

azoitl commented Sep 3, 2024

@franz-hoepfinger-4diac & @moniwe just to pre-warn you, this change will require that you need to update your global constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants