Feature request: C Switch statement
Feature request: C Switch statement
Can the C Switch statement be added to FreeBASIC? It has different functionality than the Select Case statement. Such as optional Break from Case block.
Re: Feature request: C Switch statement
You can somewhat simulate switch.
Code: Select all
#define nobreak(n) end select: select case n
Dim As Integer x=6
Print "Where is ";x;" ?"
Select Case x
Case 6
Print 6
nobreak(x)
Case 2 To 7
Print 2;" to ";7
nobreak(x)
Case 9 To 14
Print 9;" to ";14
nobreak(x)
Case 5 To 7
Print 5;" to ";7
nobreak(x)
Case 12
Print 12
nobreak(x)
Case Else
print "else ";x
End Select
Sleep
Re: Feature request: C Switch statement
It's very interesting to see someone request a C-style switch statement. Especially because not that long ago we had a discussion (I think it was here) about how bizarre and problematic the C switch construct is with it's default fall-through behavior (as eevblog says, a trap for young players). For someone coming from assembly, the C switch construct is no doubt appealing for making certain kinds of control structures. I am personally a fan of it. However I don't think it has a place in FreeBASIC to be honest.
What would be your use case for this feature?
What would be your use case for this feature?