ArmBob v.1.02 Tutorial 1                               GCW 06/06/94

Hello World
-----------
ArmBob has syntax that conforms very closely to that of C. The 
standard textbook on C is "The C Programming Language" by 
B.W.Kernighan and D.M.Ritchie (KR). If you are not acquainted with C
you will find the first few chapters of this book very useful. If
you are acquainted with C you might find it interesting to note in
which respects the examples below fail to be C programs.

Let us follow KR by considering the "first program" in any language -
a program to print the words "Hello, World". Here it is in Bob:

  main()
  {
   print("Hello, World\n");
  }

To run this program, create a text file, type the program in, and
save your file. Then drag the file to the Armbob iconbar icon
which will have appeared when you double-click !Armbob.

A Bob program consists of functions and classes. We have defined 
a single function 'main'. Normally a function can have any name you
like (subject to the rules of syntax - see ref.Syntax). However, main
is special, in that a program starts executing at main's first 
statement. Every program must have a function called 'main'.
The order in which the functions are defined makes no difference.
Classes must be defined before their instance objects are created.

The statements in a function are enclosed in braces ({ ... }). Our
program has only one statement,

                 print ("Hello, World\n");

A function is called (i.e. used) by naming it, followed by a 
parenthesized list of argument expressions. There can be blank spaces
between the function name and the opening parenthesis. Here we call the built-in
function 'print'. Most functions take a definite number of arguments,
separated by commas, but 'print' is rather special in that it can
take an indefinite number of arguments. In our example, there was the
single argument

                    "Hello, World\n"

which is a 'string' expression. Strings are sequences of characters
enclosed in double-quotes ("). They may not contain double-quotes.
The pair of characters '\n' denotes a single character - the newline.
Unlike Basic, Bob's print function does not provide a newline 
automatically. We could have written our program as

   main()
   {
    print("Hello, ","World","\n");
   }

or as 

   main()
   {
    print("Hello, ");
    print("World");
    print("\n");
   }

Bob has an alternative notation borrowed from C++. We could also
have written

  main()
  {
   stdout << "Hello, World\n";
  }

The expression 'stdout' stands for "standard output channel". If
'out' denotes any output channel, say to a file, and 'message' denotes 
a string, the statement

                    out << message;

causes message to be transmitted along out. Now the expression

                     out << message

actually evaluates to out itself. The process of evaluating it causes 
the transmission of message along out as a side-effect. It follows
that a statement of the form

           out << mesg1 << mesg2 << ..... << mesgn;

will cause mesg1, mesg2, ... mesgn all to be transmitted, in order,
along out. So we could also have written

    main()
    {
     stdout << "Hello, " << "World" << "\n";
    }

Note the distinction we made between the expression 'out << message'
and the statement 'out << message;'. The semicolon (;) marks the
termination of a single statement. Statements are like complete
sentences, but expressions are like nouns; they stand for something 
but mean nothing by themselves.



         

