Skip to content

Add specification for range types - #1181

Merged
bocchino merged 24 commits into
feature/range-typesfrom
range-types-spec
Nov 5, 2026
Merged

bocchino merged 24 commits into
feature/range-typesfrom
range-types-spec

Conversation

@bocchino

Copy link
Copy Markdown
Collaborator

This specification addresses #980 and #102. I decided to fold in #102 because it is closely related: since we are checking user-specified ranges, we should also check the ranges provided by the basic numeric types.

I updated the every expression for the throttle specifier to use a range type for microseconds.

@bocchino
bocchino requested review from Kronos3 and LeStarch October 27, 2026 15:43
@LeStarch

Copy link
Copy Markdown
Collaborator

Read through the spec. It makes sense to me.

@bocchino

Copy link
Copy Markdown
Collaborator Author

Thanks, Michael! I realized I still need to specify the default value for a range type. I think the spec can be as follows:

  • For an integer range type, the lower bound if that's valid (it's an inclusive bound) otherwise the lower bound plus one (if the lower bound is exclusive, then either this value is valid or no value is valid).

  • For an FP range type, the lower bound if that's valid; otherwise the lower bound plus twice the epsilon that we use to test for nearness to zero.

Also, I think the second requirement for a valid range type can be simplified to say "the default value must be valid for the type."

@bocchino

bocchino commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

For an integer range type, the lower bound if that's valid (it's an inclusive bound) otherwise the lower bound plus one (if the lower bound is exclusive, then either this value is valid or no value is valid).

To stay within the range of the base type, it should be: (1) the lower bound if (a) that's valid or (b) the lower bound is the max value of the base type; otherwise (2) the lower bound plus one. This rule should always produce a value of the base type that is valid for the range if and only if the range has any valid values.

@Kronos3 It turns out I did have to work out this algorithm in the spec, as you were suggesting yesterday. I realized this as I started to implement the ranges on the C++ side, and I needed static checks for these things.

@bocchino
bocchino merged commit 6f47b2c into feature/range-types Nov 5, 2026
14 checks passed
@bocchino
bocchino deleted the range-types-spec branch November 5, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants