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

Support for (physical) unit as part of datatype? #113

Open
gunnar-mb opened this issue Apr 2, 2024 · 0 comments
Open

Support for (physical) unit as part of datatype? #113

gunnar-mb opened this issue Apr 2, 2024 · 0 comments
Labels
discussion Things that need some thinking, and feedback from several to find consensus first. IFEX-spec-and-model

Comments

@gunnar-mb
Copy link
Collaborator

gunnar-mb commented Apr 2, 2024

Consider if it would make sense to add unit to datatype definitions

Traditionally, programming languages do not natively support units as part of datatype definitions, but some special programming environments might. (If you know of any, please provide links, since this may give useful design input).

Of course it doesn't prevent anyone from programming them into their 'system' using generic programming features, such as some meta-data, a string, or adding an enumeration type that lists the units, or whatever!

Design considerations

Layers are always an option, but this might be so generically useful that it ought to be part of the core language.
If units are added as an (optional) feature in the core IDL, there are still considerations:

  • Physical units such as SI / metric or other systems, usually only define them (or they only make sense) for single (scalar) values, right.
  • Therefore, defining a unit on a "Struct" makes no sense (or does it?)
  • Presumably, it would be limited to any scalar type values.
  • How should it be limited ?

Proposal 1: A datatype with a specified unit must be defined as a separate `Typedef

It would have to be enforced only by tooling implementation, that it can apply only to typedefs that apply scalar types that are only the number types, which are a subset of the primitive types (string is excluded), which in turn are a subset of the built-in types.


Proposal 2: Unit can be specified in any place where a type is specified

The same restrictions on this type being a primitive number-type would still apply.


First reaction:

In my view, number 2: feels iffy. It's somewhat more convenient, but the more "optional" fields are added to each type of definition the weaker the core IDL specification feels. It sort of gets watered down to many possible options, which doesn't feel quite right.

@gunnar-mb gunnar-mb changed the title Define units as part of datatype Support for (physical) unit as part of datatype? Apr 2, 2024
@gunnar-mb gunnar-mb added discussion Things that need some thinking, and feedback from several to find consensus first. IFEX-spec-and-model labels Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Things that need some thinking, and feedback from several to find consensus first. IFEX-spec-and-model
Projects
None yet
Development

No branches or pull requests

1 participant