Code blocks

Origo uses whitespace indentation to identify blocks of statements. The indentation rules are very simple:

  1. A new block is separated from the previous line by indenting it with one or more whitespace.
  2. Each statement within the same block is indented by the same amount, and finally
  3. A decrease of indentation signifies the end of that block.

Note that the exact amount of indentation does not matter, but the relative amount of indentation of the blocks.

Studio Assistance

In practice programming, Origo IDE offers assistance by automatically indenting your code by size one tab. By default, the tab size is two whitespaces (as in Example 1), but you can change it from the Edit/Options. There in options you can also change to manual indentation. Indenting is not only essential to the compiler, but clarifies the code structure and improves the readability.

The following two examples do exactly same regardless the different amount of indentation:

Example 1
// In this example the amount of indentation is two whitespaces
main
  // Method body is indented
  system.run application new MyApplication
  
// A decrease in indentation signifies the end of the method body 
// and the begin of a new code block           
class MyApplication extends Application
  
  // Declarations of class methods are indented
  draw to <canvas g>
    // The method boby further increases the indentation
    Size screenSize = screen.get size
    int t = system.get running time in milliseconds
    if t % 2 == 0
      // And the if statement further increases the indentation
      g.draw line from 0,0 to screenSize.get width, screenSize.get height color Color.Orange
    else
      g.draw line from 0,0 to screenSize.get width, screenSize.get height color Color.Magenta
            
Example 2
// In this example the amount of indentation is four whitespaces
main
    // Method body is indented
    system.run application new MyApplication
  
// A decrease in indentation signifies the end of the method body 
// and the begin of a new code block           
class MyApplication extends Application
  
    // Declarations of class methods are indented
    draw to <canvas g>
        // The method boby further increases the indentation
        Size screenSize = screen.get size
        int t = system.get running time in milliseconds
        if t % 2 == 0
            // And the if statement further increases the indentation
            g.draw line from 0,0 to screenSize.get width, screenSize.get height color Color.Orange
        else
            g.draw line from 0,0 to screenSize.get width, screenSize.get height color Color.Magenta