Agora-S Tutorial1

Prof. Dr. Theo D'Hondt
Last revision: August 7th, 1996

Agora-S Tutorial1


An Agora-S program usually is a block to which the µvalue message is sent.

[ .... ] µvalue
According to the abstract grammar, a block can contain all kinds of stuff. Examples are method declarations, variable declarations or just "ordinary" statements. In fact, in Agora, these are all messages albeit messages to different kinds of receivers.

For example,

[ n µvar: 1000;
  index µvar;
  index µ<- 14;
  index µfrom: 1 µto: ((n sqrt) trunc) µdo: [ .... ]
]µvalue
A full example is given below. It is an Agora-S implementation of the famous sieve of Eratosthenes:

[ n µvar: 1000;
  sieve µvar: Vector length: n of: True;
  index µvar: (Integer µclone);
  multiple µvar;
  index 
      µfrom: 1 µto: ((n sqrt) trunc) µdo:
          [ (sieve at: index)
              µthen:
                [ multiple µ<- index * 2 + 1;
                  (multiple < n)
                    µwhile:
                      [ sieve at: multiple put: false;
                        multiple µ<- multiple + index + 1]]];
   index 
       µfrom: 0 µto: (n - 1) µdo:
          [ (sieve at: index)
              µthen:
                [ (index + 1) display;
                  " is prime " display;
                  eoln display]]] µvalue
Tutorial Continued