The Iterator should have its own block!
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
This may not be an urgent proposal, but it is a logical one and a syntactic suger.
Iterator should be an independent block not a function. One obvious reason, it they don't work in the same way, nor use the same return instruction!
For example, this iterator will not compile because the return keyword is not allowed, although it seems as perfect function that should work:
```VB.NET
Public Iterator Function Foo(n As IEnumerable) As IEnumerable(Of String)
Return n
End Function
```
So, I ask to define Integrators like this:
```VB.NET
Public Iterator Foo(n As IEnumerable) As IEnumerable(Of String)
For Each i In n
Yield "Element" + i
Next
End Iterator
```
This is clearer than Iterator Function definition , and is better in lambdas because the elimination of the long word `Function`:
```VB.NET
Dim t = Iterator (n As IEnumerable)
For Each i In n
Yield "Element" + i
Next
End Iterator
```
So now, we have Sub, Function, and Iterator blocks.
This change will not break any code, because the old `Iterator Function` syntax will still working, but VB editor should change it to the 'Iterator' syntax once the code file is opened. Any new `Iterator Function` will be changed instantly to `Iterator`.
Note:
There is no such issue in C#, since there is no Function, end function keywords. So, there was no real duality to keep between the two languages when the Iterator keyword was added.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.