Io (programming Language) - Syntax

Syntax

In its simplest form, it is composed of a single identifier:

doStuff

Assuming the above doStuff is a method, it is being called with zero arguments and as a result, explicit parentheses are not required.

If doStuff had arguments, it would look like this:

doStuff(42)

Io is a message passing language, and since everything in Io is a message (excluding comments), each message is sent to a receiver. The above example demonstrates this well, but not fully. To describe this point better, let's look at the next example:

System version

The above example demonstrates message passing in Io; the "version" message is sent to the "System" object.

Operators are a special case where the syntax is not as cut-and-dried as the above examples. The Io parser intercepts a set of operators defined by the interpreter, and translates them to method calls. For example, the following:

1 + 5 * 8 + 1

translates to:

1 + (5 *(8)) +(1)

As you can see, there is also a little bit of operator precedence happening here, and the precedence levels are the same as with the C precedence levels.

Operators were also turned into method calls. In fact, all operators in Io are methods; the fact that they do not require explicit parentheses is a convenience.

Read more about this topic:  Io (programming Language)