dotnet / dotnet/vblang

[Proposal] Inclusion in the for loop of keyword "Until".

Open
#531 13 comments 3 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

In VB, the for loop is not as flexible as the for loop of other languages, for example, C#.

In vb, there is this loop:
```
Dim uA as Integer
For uA = 0 to 5
Console.WriteLine(uA+",")
Next uA
' Print:
' 0,1,2,3,4,5
```

There could also be this form:

```
Dim uA as Integer
For uA = 0 Until 5
Console.WriteLine(uA + ",")
Next uA
' Print:
' 0, 1, 2, 3, 4
```

Notice the difference between "to" and "until".
"To" is inclusive, "Until" is exclusive.

```
For uA = 0 Until 5
Next uA
```

It's similar to construction in C#:
```
for(uA = 0; uA < 5; uA++) {}
```

For me, the construction with Until is more readable than the form below in VB:
```
Dim limit as Integer
Dim uA as Integer

For uA = 1 to limit - 1
Next uA

With 'Until', it becomes less verbose:
For uA = 1 Until limit
Next
```

On MonkeyX, Monkey2 and CerberusX, what are language based on Basic, this construction exist.

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.