Wish Make some syntax optional

Troberg

Well-Known Member
Licensed User
Longtime User
Basic is an old language, and it still drags some history with it. Much has been cleaned up (such as the removal of "Let" and making "Select" and optional replacement for "Select Case".

However, there is one atavism I still find very unnecessary, and which I think should be made optional. That's the "Then" in "If" statements. Sure, it makes it more like spoken language, but, really, a clean "If" is just as readable, and provides less clutter.

Example:

B4X:
'Traditional
If Success Then
    'Do something
End If

'Improved
If Success
    'Do something
End If

By putting the condition at the very end of the line, the eye requires less scanning to find it. It would also be more in line with Select and the various loop constructs.

Don't get me wrong, I very much prefer "human language"-like languages to very compact languages, as I find myself spending more time thinking than typing, but in this case, i find that "Then" is just a useless appendix.
 

LucaMs

Expert
Licensed User
Longtime User
Basic is an old language, and it still drags some history with it. Much has been cleaned up (such as the removal of "Let" and making "Select" and optional replacement for "Select Case".

However, there is one atavism I still find very unnecessary, and which I think should be made optional. That's the "Then" in "If" statements. Sure, it makes it more like spoken language, but, really, a clean "If" is just as readable, and provides less clutter.

Example:

B4X:
'Traditional
If Success Then
    'Do something
End If

'Improved
If Success
    'Do something
End If

By putting the condition at the very end of the line, the eye requires less scanning to find it. It would also be more in line with Select and the various loop constructs.

Don't get me wrong, I very much prefer "human language"-like languages to very compact languages, as I find myself spending more time thinking than typing, but in this case, i find that "Then" is just a useless appendix.


This is similar to use:

Private Done As Boolean

If Done = True "then"
End If

instead of:

If Done "then"
End If


Instead, they have eliminated:
For i = 0 ...
Next I

I think that the code is more correct, more readable with the variable in the Next statement, especially in nested loops.
 

Troberg

Well-Known Member
Licensed User
Longtime User
I prefer

If Done then

over

If Done=True then

(and, as you can might, without the "then"...).

As for the next, I prefer the clean "Next" over "Next i", and, in the few cases I get deeply nested structures, I simply use a comment to clarify, such as

For i = 0 to 100
If Correct then
...
Else 'Not correct
...
End if 'Correct
Next 'i

It's very seldom I need it, though.
 
Top