dotnet / dotnet/vblang

Ranged Data Types

Open
#223 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

I suggest to improve current numeric types by adding a way to set a value range. I don't ask for numeric range array . I want a limited value range variable that can have a single value within the range. This is a sort of value validation, that can be applied to Properties and will affect binding them to data entry controls.
This can be done by adding two readonly properties to each data type: Min, Max. The compiler should check them before assigning any value to the object.
Max and Min Values can also be set via the constructor.
The can be done also by some attributes, but it will be easier to give it a syntax like this

Dim I As Integer[5,10] = 7
or
Dim I As Integer<5,10> = 7
The compiler must not allow I to have any value < 5 or >10.
One can omit one limit:
Dim I As Integer [,100] = 20
Dim I As Integer [13,] = 15
or
Dim I As Integer <,100> = 20
Dim I As Integer <13,> = 15
This will make it easy to write auto-properties like this:
Property Age As Integer[18,30]
Or
Property Age As Integer<18,30>

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.