microsoft / microsoft/typespec
Numeric range literal
Open
design:needed
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Was thinking about this the other day, could have have a built-in syntax for defining a numeric range `1..10`
```tsp
alias OneToTen = 1..10
```
think that could be useful for defining status code ranges in http library `200..299`
## Potential syntax
Assuming we have a way to specify the precision/type of a number literal with `i` `f` suffix.
Would follow `..` for inclusive `...` for exclusive upper bound following the way it works in ruby
```tsp
alias IntInclusive = 1i..3i // 1,2,3
alias IntExclusive = 1i...3i // 1,2
alias floatInclusive = 0f..3f // >= 0, <=3
alias floatExclusive = 0f...3f // >= 0, <3
```
Contributor guide
Assessment
This issue has not been assessed yet.