Skip to content

Proposal for enhancement of phlex::experimental::identifier #878

Description

@marcpaterno

The class phlex::experimental::identifier (from now on, just identifier) is in some contents where it is critical that the string never be empty, and in a few where it is allowable for the string to be empty.

For example, in phlex::detail::product_specification, the member suffix_ is an identifier that is allowed to be empty.
In phlex::experimental::algorithm_name (which is the unique identifier for a node in the graph), the member plugin_ is arguably allowed to be empty, while the member algorithm_ is not allowed to be empty.
In phlex::experimental::layer_path, the member layer_path_ is a std::vector<identifier> none of which should be empty.

The non-emptiness is not always currently enforced at runtime.
There has also been an intent to enforce other restrictions on identifiers, e.g. issue #343 to ensure that identifiers when turned into a std::string are valid C++ variable names.

I propose a change that would make the non-empty nature of identifier be a class invariant for the type, accompanied by the introduction of a new type that can have the state that represents either an identifier or an empty string; this type could have type aliases of suffix_t and plugin_name_t.

This would allow use of identifier as a type in code that would then never need to check if the "string" is empty, for example if emitting the stringified version as a label in a JSON/YAML/FHiCL document, etc., while allowing suffixes and plugin names to be empty when desired.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions