Skip to content

End for loops with END and avoid escaping keywords inside loops #3009

Closed

Description

@pekkaklarck

At the moment for loops require using \ before keywords inside the loop:

FOR    ${var}    IN    1    2    3
\    Keyword    ${var}
\    Another keyword
Keyword outside loop

This is pretty awkward and not something we want to use if/when we add more control structures or especially if/when we add nested control structures. We were thinking alternatives already in #2783 and considered using | instead of \ (not that much better), Python style indentation using whitespace (likely lot of backwards-compatibility problems) and using explicit END at the end like in Ruby. That issue also proposed changing old :FOR (case-insensitive) to FOR (case-sensitive) and that has been already covered by #2990.

We've now made a decision to go with the END at then end. It makes for loop syntax quite a bit nicer:

FOR    ${var}    IN    1    2    3
    Keyword    ${var}
    Another keyword
END
Keyword outside loop

This syntax will be supported already in RF 3.1 and the old syntax also works without any deprecation at that point. The old syntax will, however, be deprecated in RF 3.2 to allow adding more/nested control structures hopefully already in RF 3.3.

Activity

  1. added this to the v3.1 milestone on Nov 21, 2018
  2. pekkaklarck commented on Nov 21, 2018

    @pekkaklarck
    MemberAuthor

    Notice that when \ can be omitted, the indentation inside loops will be ignored similarly as in most programming languages (Python obviously being an exception). In other words, also the following will work (but won't be recommended):

    FOR    ${var}    IN    1    2    3
    Keyword    ${var}
    Another keyword
    END
    
  3. changed the title [-]Support ending for loops with optional `END`[/-] [+]Support ending for loops with `END` and omitting escaping with `\`[/+] on Nov 21, 2018
  4. pekkaklarck commented on Nov 21, 2018

    @pekkaklarck
    MemberAuthor

    Initially this issue was only about adding optional END at the end of for loops so that we could later require it and allow omitting \ used for indenting keywords inside loops. It turned out that allowing \ to be omitted is pretty easy as well, so this issue is now changed to cover both. Need to update the description accordingly as well.

  5. changed the title [-]Support ending for loops with `END` and omitting escaping with `\`[/-] [+]End for loops with `END` and avoid escaping keywords inside loops[/+] on Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions