# A simple example

Here's a simple program composed of a main module, an imported interface and its implementation.

To begin, create a fresh directory for the package and within that directory, a directory for the source files:

        > mkdir hello
        > cd hello
        > mkdir src

Create the following source files in the `src` directory:

In the file `src/Main.m3`:

        MODULE Main;
        IMPORT A;
        BEGIN
          A.DoIt ();
        END Main.

In the file `src/A.i3`:

        INTERFACE A;
        PROCEDURE DoIt ();
        END A.

In the file `src/A.m3`:

        MODULE A;
        IMPORT Wr, Stdio;

        PROCEDURE DoIt () =
          <*FATAL ANY*>
          BEGIN
            Wr.PutText (Stdio.stdout, "Hello world.\n");
            Wr.Close (Stdio.stdout);
          END DoIt;

        BEGIN
        END A.

In the file `src/m3makefile`:

        import ("libm3")
        implementation ("Main")
        module ("A")
        program ("foo")

Finally, from the package directory, `hello`, run `m3build`. If the compiler is installed correctly, it will compile the three source files and link them with the standard libraries. The derived files will be placed in a directory that names the architecture. On a 80x86 Linux machine, the directory is called `LINUXELF`. The executable program will be named `foo` in the derived directory.

    Last modified on Thu Jan  4 11:08:07 PST 1996 by heydon
         modified on Tue Jan  3 07:38:22 PST 1995 by kalsow
         modified on Thu Jan  7 18:40:57 PST 1993 by muller