Skip to content

Explicit units design #6

Description

@burnpanck

Spec section

SPEC 7.2

The question or problem

I just noticed this project, and I find the premise intriguing. I am a big defender of meaningful representations, and and am happy to see that this design considers the question of the units used for representing physical quantities. However, if I understood correctly, the units are only attached as a description, and everything from code to wire format still uses numbers (floats).

IMHO, that is unnecessarily brittle. You can change a description, and nothing breaks visibly in software, while in the physical world, the effect breaks havoc. I recommend the following: Always carry the unit with the value. Never split the two into a number and something that lives somewhere else (like a description) - because semantically, these individual parts have no meaning and thus are uncheckable. Only the combination is. In practice, that means using something like pint.Quantity on the server/bridge implementation side, and define your RPC wire format in a way that it can carry unit information with the value; in JSON, we typically use value a string combining magnitude and unit in one value, and rely on the RPC schema to turn the string back into a quantity. In tagged formats like YAML, a tag identifies the value as a quantity, and allow both a single string or a number/unit pair.

What you were building

No response

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