Stupid Question of the Day: Love for THEN?

  1. 2 weeks ago

    Jim F

    Nov 26 Pre-Release Testers, Xojo Pro

    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

  2. Markus R

    Nov 26 Pre-Release Testers, Xojo Pro Europe / Germany
    Edited 2 weeks ago

    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.

  3. Rick A

    Nov 26 Pre-Release Testers (Brazil. UTC-3:00)
    Edited 2 weeks ago

    @Jim F THEN? Is there some significance I am not aware of?

    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".

  4. Kem T

    Nov 26 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

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

  5. Markus R

    Nov 26 Pre-Release Testers, Xojo Pro Europe / Germany
    Edited 2 weeks ago

    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
  6. Tomas J

    Nov 26 Pre-Release Testers, Xojo Pro Europe (Germany)

    let's do the python way, more efficient ;-)

    if x<10 
         x=x+1
  7. Markus R

    Nov 26 Pre-Release Testers, Xojo Pro Europe / Germany
    Edited 2 weeks ago

    @Tomas J more efficient

    x+1<10
    x<10 x+1

  8. Beatrix W

    Nov 26 Pre-Release Testers, Third Party Store Europe (Germany)

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

  9. Dave S

    Nov 26 San Diego, California USA
    Edited 2 weeks ago

    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.

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

    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
  10. Karen A

    Nov 26 Pre-Release Testers

    @Dave S Sometimes I think that Xojo should enforce case-sensitivity (as Swift does), but sometimes I'm glad it doesn't.

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

    -Karen

  11. Dave S

    Nov 26 San Diego, California USA

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

    -Karen

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

  12. Kem T

    Nov 26 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    That would allow code like:

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

    No thanks.

  13. Dave S

    Nov 26 San Diego, California USA

    @Kem T That would allow code like:

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

    No thanks.

    yes it would, and many other languages do (which lead to the 'sometimes I don't' part of my statement :) )

  14. Kem T

    Nov 26 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

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

  15. Dave S

    Nov 26 San Diego, California USA

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

  16. Norman P

    Nov 26 Pre-Release Testers, Xojo Pro under a bus

    @Tomas J let's do the python way, more efficient ;-)

    if x<10 x=x+1

    OH GAWD 100 dislikes

  17. Karen A

    Nov 26 Pre-Release Testers
    Edited 2 weeks ago

    @Dave S just enforces a different discipline is all... and the compiler would point out where you missed :)

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

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

    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.

  18. Neil B

    Nov 26 Pre-Release Testers

    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.

  19. Michel B

    Nov 26 Pre-Release Testers, Xojo Pro

    If I recall, then was optional in VB.

  20. Rick A

    Nov 26 Pre-Release Testers (Brazil. UTC-3:00)

    @Michel B If I recall, then was optional in VB.

    For multiline, yes:

    ' Multiline syntax:
    If condition [ Then ]
        [ statements ]
    [ ElseIf elseifcondition [ Then ]
        [ elseifstatements ] ]
    [ Else
        [ elsestatements ] ]
    End If
    
    ' Single-line syntax:
    If condition Then [ statements ] [ Else [ elsestatements ] ]

    Also "*statements" could be "statement" or "statement : statement ..."

  21. Newer ›

or Sign Up to reply!