Home Contents Next

Chapter 1: Introduction

1.1 What is Aldor?

1.2 Compling and running a single file

1.3 This guide

1.4 Reporting problems

1.1 : What is Aldor?

The original motivation for Aldor came from the field of computer algebra: to provide an improved extension language for the AXIOM system

The desire to model the extremely rich relationships among mathematical structures has driven the design of Aldor in a somewhat different direction than that of other contemporary programming languages. Aldor places more emphasis on uniform handling of functions and types, and less emphasis on a particular object model. This provides the flexibility necessary to solve the original problem, and has already also proved of significant use outside of this initial context.

The primary considerations in the formulation of Aldor have been generality, composibility and efficiency. The Aldor language has been specifically designed to admit a number of important optimizations, allowing compilation to machine code whose efficiency is frequently comparable to that produced by a good C or Fortran compiler.

Aldor is unusual among compiled programming languages, in that types and functions are first class that is, both types and functions may be constructed dynamically and manipulated in the same way as any other values. This provides a natural foundation for both object-oriented and functional programming styles, and leads to programs in which independently developed components may be combined in quite powerful ways.

Two novel features of Aldor are dependent types, which allow static checking of dynamic objects, and post facto type extensions, which allow complex libraries to be separated into decoupled components.

The Aldor compiler described in this Guide can produce:

The object libraries produced by the Aldor compiler can be linked with one another, or with C or Fortran code, to form application programs. The byte code libraries can be interpreted, and are used by the compiler for inter-file optimization. The Lisp code generated by Aldor may be embedded in Lisp-based applications, including AXIOM.

The Aldor distribution includes:

A detailed list is given in chapter 29.

The Aldor compiler has been designed for portability and runs in many different environments, including DOS/Windows, OS/2, VMS, CMS, Macintosh System 7 and several Unix-derivatives. Code generated by Aldor will run on 16, 32 and 64-bit architectures.

A list of Aldor ports at the time of writing is given later on. For an up-to-date list of available implementations, please contact Nag

1.2 : Compiling and running a single file

The first thing many people want to do is compile and run a simple test file. This section shows how to do this.

We start with an Aldor source file, "sieve.as", containing the simple program shown below.

Fig 1.1: An Aldor program.

-- sieve.as: A prime number sieve to count primes <= n.
# include "aldor.as"

import from Boolean, SingleInteger;

sieve(n: SingleInteger): SingleInteger  == {
        isprime: PrimitiveArray Boolean := new(n, true);

        np := 0;
        for p in 2..n | isprime p repeat {
                np := np + 1;
                for i in 2*p..n by p repeat isprime i := false;


for i in 1..6 repeat {
        n := 10^i;
        print << "There are " << sieve n << " primes <= " << n;
        print << newline;

To compile this file and run the resulting executable program, use the following commands:

In this example ``%'' is the operating system command line prompt and should not be typed. On most platforms the command to run the Aldor compiler is ``aldor''.

The ``aldor'' command takes the source file "sieve.as" and produces a file of machine code which can perform the computation. The executable program is named according to the operating system's usual conventions: for instance, "sieve" on Unix, or "sieve.exe" on DOS. Once compiled, the new program can be used in the same way as other executable programs for the given operating system.

Command line options control the behaviour of the compiler. For example, the option "-Fx" in the previous example directs the compiler to produce an executable file.

There are many available command line options, regulating different aspects of the compiler's actions. They allow you to control the details of what the compiler actually does. Here we point out a few of the most important options -- the rest are described in detail in
chapter 27.

Keep in mind that you do not need to remember very much. The only option you really need to know is "help", which gives help. The command is:

Another thing to keep in mind is that you can make your programs run much faster by asking the compiler to optimize them. The "-O" option tells the compiler to do this:

Depending on the way in which Aldor has been installed on your computer, you may need to set some system-specific variable or macro so that the compiler can find its libraries. The value for this will depend on where Aldor is installed. For example, on one of our local Unix systems, this is achieved by setting the "environment variable" "ALDORROOT" to

To be able to use Aldor on this particular system, one might put the following commands in a (Bourne or Korn shell) initialization file:

Please refer to your system administrator for details of the corresponding setup on your particular computer system.

1.3 : This guide

This guide describes the Aldor programming language, a compiler and an interpreter, and other related software.

Part I:The first two chapters provide a quick, informal introduction to Aldor.

Chapter 1 provides an introduction and indicates how to compile and run simple programs. It gives a very brief description of what Aldor is and what the compiler can do. Section 1.4 explains how to report problems.
Chapter 2 discusses a number of (mainly) very simple programs.

Part II: The next chapters provide a guide to the Aldor programming language.

Chapters 3 to 14 present in detail the various aspects of the language and provide a number of illustrative examples.

Other chapters in this Guide can also be useful in learning about the language. A more leisurely introduction to some topics, including an extended example of building a new type from scratch, is given in chapter 21. Additional programming examples are discussed in chapter 23. The formal language syntax is given in chapter 24.

Part III:The next six chapters serve as a guide to the Aldor compiler and related software.

Chapter 15 explains how to interpret and control messages from the compiler.
Chapter 16 describes how to build an Aldor program from several separately compiled files.
Chapter 17 shows how to use the Aldor compiler interactively, to compile and evaluate a line of code at a time.
Chapter 18 explains how to use Aldor as a tool to extend the AXIOM system. Programs written in Aldor can have full access to the axiom library and are understood by Version 2.0 of the AXIOM system.
Chapter 19 shows how to write Aldor programs which call C programs and vice versa.
Chapter 20 describes XAldor, a graphical user interface environment which communicates with the Aldor compiler for compiling and debugging programs.

Part IV:The next three chapters provide tutorial lessons and are provided to help learn the language.

Chapter 21 is a tutorial on Aldor by Tim Daly from the point of view of an experienced AXIOM programmer. This tutorial provides a leisurely development showing how to do in Aldor the kinds of things done in the AXIOM library.
Chapter 22 is a narrative by Robert Corless, relating his experiences as a complete novice to Aldor. This chapter is organized as a series of vignettes, describing what he learned from each of his initial Aldor programs.
Chapter 23 provides a number of detailed sample programs. This includes examples which range from trivial half-page programs to a complete X Window System R11 application. These provide concrete illustrations of how to use the various aspects of the programming language.

Part V:The remaining chapters provide reference material, and are not intended to be read sequentially.

Chapter 24 is a formal description of the language syntax.
Chapter 25 and 26 describe the base Aldor library. This library can be used by stand-alone Aldor programs, or Aldor code linked into C-based applications. For this release, it is not possible to use this library together with the axiom library.
Chapter 27 provides a detailed description of the "aldor" command. It describes the types of files, all the options, and the environment variables understood by the compiler.
Chapter 28 discusses the use of the back-end compiler and linker driver unicl.
Chapter 29 lists all the messages which the compiler can produce. The names of the messages are also listed so you can turn off the specific messages if you wish.
Chapter 30 gives a detailed list of the components of the Aldor distribution directory.

Part VI:The remaining chapters provide documentation for the features added at Version 1.1.12 of the compiler

Chapter 31 introduces the exception handling mechanism.
Chapter 32 discusses the facilities for linking FORTAN code with Aldor.

1.4 : Reporting problems

If you discover an error in the Aldor compiler, libraries, or companion software we want to know about it so we can fix it.

When reporting a problem, please supply the precise compiler version and have a file that demonstrates the problem. To determine your compiler version, use the "-v" option to cause the Aldor compiler to operate verbosely. The first output line will contain the compiler version. For example,

On Unix-derivative systems, the Aldor distribution contains a program called "aldorbug" for electronically mailing bug reports. The "aldorbug" program prompts the user for information; the responses in the example below are shown in italics:

Fig 1.2: Aldor Ports

Aldor VersionProcessorOperating SystemSubordinate C Compiler
Unix derivatives
1.1.12 linuxIntel i386LinuxGNU C
1.1.12 rs4.1IBM RS/6000AIX 4.1IBM XLC
1.1.12 sun4os4gSun SparcSunOS 4.1.xGNU C
1.1.12 sun4os55gSun SparcSunOS 5.5GNU C
1.1.12 sun4os55cSun SparcSunOS 5.5SUNPRO
1.1.12 irixmips1MIPS IIRIX 5MIPS C
1.1.12 irixmips3MIPS IIIIRIX 6MIPS C
1.1.12 hpuxHPHP/UX 10HP C
1.1.12 axposfl v4DEC AlphaOSF/1(V4.0)DEC C
1.1.10 sun4os4cSun SparcSunOS 4.1.xSun C (K&R)
1.00.6 rsgccIBM RS/6000AIX 3.2GNU C
0.33.0 aixrtIBM RT/PCAIX 2.2IBM C (K&R)
0.35.0 aixesaIBM S/370AIX/ESAMetaware C
0.33.5 nextMotorola 680x0Next MachGNU C
DOS, Windows
0.28.0 dosbccIntel i386 (16 bit)DOS 5.0Borland C++
1.00.0 dosgccIntel i386 (32 bit)Dos 5.0
Windows 3.1
0.23.0 os2cset2Intel i386OS/2 2.0IBM C Set 2
0.28.0 os3bccIntel i386OS/2 2.0 borland C++
0.36.0 macsys7Motorola 680x0System 7*
* macppxPower PCSystem 7 Metrowerks C
0.31.0 cmsIBM S/370VM/CMSC 370

* in progress

Entries in this table do not imply commercial availability.

Home Contents Next