7.2. Toplevel Syntax

The synatax is slightly different if you enter statements on the top level versus when they are inside parentheses or inside functions. On the top level, enter acts the same as if you press return on the command line. Therefore think of programs as just sequence of lines as if were entered on the command line. In particular, you do not need to enter the separator at the end of the line (unless it is of course part of several statements inside parenteses).

The following code will produce an error when entered on the top level of a program, while it will work just fine in a function.

if Something() then
  DoSomething()
else
  DoSomethingElse()

The problem is that after Genius Mathematics Tool sees the end of line after the second line, it will decide that we have whole statement and it will execute it. After the execution is done, Genius Mathematics Tool will go on to the next line, it will see else, and it will produce a parsing error. To fix this, use parentheses. Genius Mathematics Tool will not be satisfied until it has found that all parenteses are closed.

if Something() then (
  DoSomething()
) else (
  DoSomethingElse()
)