awful: tutorial: hello world!

:writeln s'Hello world!'

Above is awful code for the simplest Hello world! script. This piece of code, when run, will simply print Hello world! and exit. So, let's take a moment to analyse this snippet, shall we?

Anyone who ever touched *nix should be familiar with this. Shebang tells the OS what program to run the script with. Similar to shell scripts, awful uses the hash (#) character for comments. Everything after a hash character, until the end of the current line, is ignored. You can place multi-line comments using the #~ and ~# digraphs - everything between them will be ignored.

This is a call to the :writeln function. All function calls in awful are prefixed with the colon (:) character. After the function name, a list of arguments follows. As can be guessed, the :writeln function takes its arguments and prints them on standard output.

s'Hello world!'
This is a string literal. All strings in awful are prefixed with the lowercase letter S (s). The next character after the prefix is used as string delimiter. This can be any character, even including characters which have a special meaning in awful (space, hash, parentheses, brackets, pipe, tilde).

To sum up, the example above features a line of commentary, and then another line containing a call to the :writeln function. The function is passed one parameter - a lone string literal.

Statement separation
In awful, statements are separated by inserting a newline. This means that it is impossible for a function call, or string literal, to span over multiple lines. If needed, one can put multiple statements on the same line by inserting the tilde (~) between them, which acts as a statement separator.

Next: ⇒ Data types ⇒
Back: ⇐ About ⇐

wikipage modified on 2014/0601/2317