dotnet / vblang

The home for design of the Visual Basic .NET programming language and runtime library.
289 stars 65 forks source link

Ranged Data Types #223

Open ghost opened 6 years ago

ghost commented 6 years ago

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>

ghost commented 5 years ago

Why there is no response on this till now?