Blocks

Blocks

Indentation

IWML depends on strict indentation. Python and other languages also rely on indentation. While usage of indentation may seem foreign to many, it greatly simplifies and makes the reading of IWML much cleaner. Even if you are among those who find it unusual, you will adapt quickly to it and likely become fond of it simplicity.

All blocks in IWML denote their children by an indent of exactly 2 spaces. Not a tab character, but exactly 2 spaces.

In this example we have taken the previous IWML and replaced the spaces with the = character to illustrate:

ACORN 1.0 IWML 1.0
Page[]
==SimpleStack[]
====Text Hello
====Text World
====Button Ok
==]
]

Block End

Blocks are closed by a single ] (right square bracket) of the same indent as the opening statement.

ACORN 1.0 IWML 1.0
Page[]
  SimpleStack[]
    Text Hello
    Text World
    Button Ok
  ]
]

The first blue ] aligns with SimpleStack[] and closes its block. The second ] aligns with Page and closes its block.

Block Begin

While one might expect a [ to signify opening of a block, this is not the case and intentionally so. Using a [ to open a block would require an extra line or would interfere with parameters during parsing. By not using [ for block opening, IWML remains far simpler without the need to escape parameters, and without the need for extra lines peppered throughout the IWML which would increase the visual size of IWML greatly and unnecessarily so.

Because of parameters and other syntax it is not feasible to put [ on the same line, and putting [ on its own line would increase line count without any tangible benefit. Consider the following example:

ACORN 1.0 IWML 1.0
Page[]
[
  SimpleStack[]
  [
    Text Hello
    Text World
    Button Ok
  ]
]

Note that the preceding is not valid IWML and is shown only for illustration purposes.

In this example both of our statements that begin a block end in [], but this is not always the case and [] instead signifies that children exist in the block rather than properties. The beginning of the block is defined by the indent. Not all controls support blocks.