Proposal: Add Property lambda Expressions
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Based on #397 , this syntax can be generalized to be used outside Xml literals, by wrapping a code block in `Get` `End Get` like This:
```VB.NET
Dim X = Get
' Some code
Return Some Value
End Get
```
This is a ReadOnly Property lambda Expression, which can be implemented as real property (which will need many params to pass the local variables, and I think this is not appropriate although VB properties can have params), or It can be implemented directly as a full function that receives the local vars.
It also can be implemented to lambda function:
```VB.NET
Dim X = (Function( )
' Some code
Return Some Value
End Function) ( )
```
It may seems that the second syntax (lambda function) is not too long than the first one (lambda property), but I always feel that calling lambda expression inline is confusing and less readable.
Another example:
```VB.NET
Dim Count = ReadCount()
Dim Msg = Get
Select Case Count
Case 1
Return "One Item"
Case 2
Return "Two Items"
Case Else
Return "Many Items"
End Select
End Get
```
Not: this proposal doesn't cancel #397. I still want to get rid of `(Function() End Function) ( )` and `Get ...End Get` inside xml, and interpolated strings. Inside any literal that has a notation to substitution, there is no need to wrap code in any other container, unless there is a need to do further calculation on the returned value (like summation).
VB was always smart, and should continue this way.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.