[Proposal] Local and generic aliases for types
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
I came across this vb code:
```VB.NET
Public ReadOnly Property Includes As List(Of Expression(Of Func(Of T, Object))) =
New List(Of Expression(Of Func(Of T, Object)))()
```
and I said: this complexity can't be a VB code!
And I wondered: Can't I simplify this to:
```VB.NET
Imports Expr = Expression(Of Func(Of T, Object))
Public ReadOnly Property Includes As List(Of Expr) =
New List(Of Expr)()
```
This seems more like VB code.
But unfortunately it is not possible, since T exists only inside the class scope, and Imports exists only in file/namespace scope!
So, I wish if VB allows importing type aliases inside classes (the first lines after inherits and implements). This is a must in today's projects that contain very complex generics and lambdas that make our heads spin.
Another good idea, is to allow declaring generic aliases at the file level:
```VB.NET
Imports Expr(Of T) = Expression(Of Func(Of T, Object))
```
So, we can use it in the class like this
```VB.NET
Class Foo(of T)
Public ReadOnly Property Includes As List(Of Expr(Of T)) =
New List(Of Expr(Of T))( )
End Class
```
This is a bit longer, but we can use Expr(Of T) in all classes in the same file.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.