[Proposal] Tuple Sub-Clauses
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
# Tuple Sub-Clauses
I would like to use `TupleSyntax` as both argument to a `Select Case` and as arguments to a `Case` clause.
Those tuple clauses each action as sub-clause, where all of the sub-clauses have to match, for the case to be consider a valid option. These sub-clause would be the current permitted clauses, with a few additional ones.
```
Is Nothing ' Is this sub-clause nothing?
IsNot Nothing ' Is this sub-clause not nothing?
' An empty sub-clause standing for "Not Applicable" or "I Don't Care"
```
Consequences
```vbnet
Select Case ( arg0, arg1, arg2)
Case ( , , )
' Always True
Case Else
' Never Executed
End Select
```
## Example
Suppose we have the following class.
```vbnet
Class IsTypeClause Inherits SyntaxNode
Public ReadOnly Property KindOfIsKeyword As KeywordSyntax
Public ReadOnly Property DeclarationAs As Optional(Of DeclarationAsClause)
Public ReadOnly Property KindOfTypeTarger As Union(Of TypeArgumentListSyntax, TypeSyntax)
End Class
```
And then overrides a function that returns then kind of this node.
```vbnet
Overrides Function GetNodeKind() As SyntaxKind
Select Case ( Me.KindOfIsKeyword , Me.DeclarationAs , Me.KindOfTypeTarget)
Case ( Is SyntaxKind.IsKeyword , Is Nothing , Is TypeSyntax) : Return SyntaxKind.IsTypeClause
Case ( Is SyntaxKind.IsKeyword , Is Nothing , Is TypeArgumentListSyntax) : Return SyntaxKind.IsTypesClause
Case ( Is SyntaxKind.IsKeyword , IsNot Nothing , Is TypeSyntax) : Return SyntaxKind.IsTypeClauseWithDecl
Case ( Is SyntaxKind.IsKeyword` , IsNot Nothing , Is TypeArgumentListSyntax) : Return SyntaxKind.IsTypesClauseithDecl
Case ( Is SyntaxKind.IsNotKeyword, Is Nothing , Is TypeSyntax) : Return SyntaxKind.IsNotTypeClause
Case ( Is SyntaxKind.IsNotKeyword, Is Nothing , Is TypeArgumentListSyntax) : Return SyntaxKind.IsNotTypesClause
Case ( Is SyntaxKind.IsNotKeyword, IsNot Nothing , Is TypeSyntax) : Return SyntaxKind.IsNotTypeClauseithDecl
Case ( Is SyntaxKind.IsNotKeyword, IsNot Nothing , Is TypeArgumentListSyntax) : Return SyntaxKind.IsNotTypesClauseithDecl
Case Else : Return SyntaxKInd.IsTypeClause_Invalid
End Select
End Function
```
If the compiler had some smarts, rather than lowering this to the naive implementation of a list of `If Then` and `ElseIf ` `Else` `End If` statements. That it could be lowered to a set of nested if statements, reducing the number of comparison checks.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.