Skip to content

Constants: clarify type #573

@thorehusfeldt

Description

@thorehusfeldt

The current 2025-09 says, under constants:

A constant value is either a scalar (integer, float, or string), or a map with a required value key (integer, float, or string) and optional variant keys providing alternative representations.

This does not specify the type of a “variant” key.

I think it should be string. To be precise, I suggest this schema:

	constants?: [=~"^[a-zA-Z_][a-zA-Z0-9_]*$"]: int | float | string | {
		value!:               int | float | string
		[string & !="value"]: string
	}

If not, we don’t know that this means:

constants:
  k:
    value: 5000000
    tex: 5,000,000
    mystery: 5.000
    scientific: 5 \cdot 10^6

We would need to rely on the YAML parser or editor to tell us what k.mystery is (here: the float 5.0). The spec says “a representation”, which can mean many things to many people, including __repr__(). Had I written mystery: 5.000,000 I would need to understand how YAML (a notoriously ill-specified standard) interprets that value (here: the string "5.000,000".)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions