Stupid Question of the Day: Love for THEN?

So with all the language updates in 2019r2.1 ; are we still in love with THEN? Is there some significance I am not aware of? It is probably the most common compiler error I see. Every time I see the red ‘X’, I am like - really? “Why don’t you just put it in there and continue compiling!” Even after years of typing it sometimes the brain continues the thought and I continue typing - grammar and syntax excluded from thought - and there is sits, the lonely IF missing its pal THEN.

I’m not advocating the extinction of THEN, just a consideration of -
• Ignoring it during compile (being there, or not to be)
• Automatically adding it (compiler) if it is missing

because Xojo can also write key words CamelCase after leave the row i think it can also add a Then if it is missing. (optional)
Automatically adding anything by compiler i not like. should be part of analyse project and there a option to auto replace/add.
and maybe analyse project preceding the build process.

for a better understanding of source code reading “Then” should follow after the condition.

or as example app game kit editor have short cuts which the user can define self
so you can write if and press TAB the row appear if then and the cursor goto after if where you defined. very useful this feature.

Xojo does not have begin/end block keywords as pascal or delimiters { } as C++, but it depends on different delimiter-keywords in context. If you don’t write the starting THEN knowing it’s necessary, probably you forgot to conclude some expression. I love the compiler showing it. And THEN allows you doing things like IF x<10 THEN x=x+1, imagine writing IFx<10 x=x+1, it’s great that we receive a “hey? I can’t find a THEN ending your IF expression”.

Did you know that pressing shift-return after writing the condition, before Then, will fill in both Then and End If for you?

i know one basic language that allow “Then” optional at multiline. (i not like it because its inconsequent/varying)

IF x<10 x=x+1 End If

let’s do the python way, more efficient :wink:

if x<10 
     x=x+1

x+1<10
x<10 x+1

The white-space in Python drove me nuts. Together with the case-sensitivity and the multiple returns from a function.

THEN should continue to be an included and required part of the language syntax… as it provides for continuation of the statement, and contributes to the readability of the code.

Sometimes I think that Xojo should enforce case-sensitivity (as Swift does), but sometimes I’m glad it doesn’t. but functions that can return multiple values would be REALLY nice (and Swift also has this)

(x,y,z)=myFunction

Were you aware that THEN is optional on the Pragma statements?

#If TargetMacOS
#endif

[quote=464798:@Dave S]Sometimes I think that Xojo should enforce case-sensitivity (as Swift does), but sometimes I’m glad it doesn’t.
[/quote]

Case sensitivity for identifiers would definitely be a deal breaker for me!!!

-Karen

[quote=464799:@Karen Atkocius]Case sensitivity for identifiers would definitely be a deal breaker for me!!!

-Karen[/quote]
just enforces a different discipline is all… and the compiler would point out where you missed :slight_smile:
but what I do miss in Swift is that compares ARE sensitive without special consideration, the opposite of what Xojo does.

That would allow code like:

dim myVar as integer
dim MYVAR as string
dim myvar as DateTime

No thanks.

[quote=464801:@Kem Tekinay]That would allow code like:

dim myVar as integer
dim MYVAR as string
dim myvar as DateTime

No thanks.[/quote]
yes it would, and many other languages do (which lead to the ‘sometimes I don’t’ part of my statement :slight_smile: )

JavaScript is like that. On a side note, I despise JavaScript… :stuck_out_tongue:

opps… we slipped off topic… the topic police should be here any second (sarcasm)

[quote=464793:@Tomas Jakobs]let’s do the python way, more efficient :wink:

if x<10 x=x+1 [/quote]
OH GAWD 100 dislikes

[quote=464800:@Dave S]just enforces a different discipline is all… and the compiler would point out where you missed :slight_smile:
[/quote]

Not necessarily … I am perfectly capable of forgetting already dimmed a variable and din it again but with diffeenatg capitalization!

[quote]
but what I do miss in Swift is that compares ARE sensitive without special consideration, the opposite of what Xojo does.[/quote]

I just wish we had different case sensitive OPERATORS (so faster) …

Maybe something like:

@= as case sensitive = @< As case sensitive < @> As case sensitive >

And if used with anything else beside strings on both sides not compile, OR act as the normal operators.

Linting in Xojo would really help.

https://www.freecodecamp.org/news/what-is-linting-and-how-can-it-save-you-time/

Ignore the grandma looking for a semi-colon.

If I recall, then was optional in VB.

For multiline, yes:

[code]’ Multiline syntax:
If condition [ Then ]
[ statements ]
[ ElseIf elseifcondition [ Then ]
[ elseifstatements ] ]
[ Else
[ elsestatements ] ]
End If

’ Single-line syntax:
If condition Then [ statements ] [ Else [ elsestatements ] ][/code]

Also “*statements” could be “statement” or “statement : statement …”