Home
Contents
Next
Chapter 1: Introduction
1.2 Compling and running a single file
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.
To compile this file and run the resulting executable program, use
the following commands:
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;
}
np
}
for i in 1..6 repeat {
n := 10^i;
print << "There are " << sieve n << " primes <= " << n;
print << newline;
}
% aldor -Fx sieve.as
% sieve
There are 4 primes <= 10
There are 25 primes <= 100
There are 168 primes <= 1000
There are 1229 primes <= 10000
There are 9592 primes <= 100000
There are 78498 primes <= 1000000
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
``
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:
% aldor -help
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:
% aldor -O -Fx sieve.asDepending 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
/u/aldor/server/aldor/base/sungcc
To be able to use Aldor on this particular system,
one might put the following commands in a
(Bourne or Korn shell) initialization file:
ALDORROOT='/u/aldor/server/aldor/base/sungcc' PATH=$ALDORROOT/bin:$PATH export ALDORROOT export PATH
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,
% aldor -v big.as
A# version 0.35.0 for AIX ESA
ld in sc sy li pa ma ab ck sb ti gf of pb pl pc po mi
Time 1.1 s 0 2 6 2 3 9 1 1 1 7 58 7 2 1 0 0 0 1 %
Source 1025 lines, 53478 lines per minute
Lib 3616 bytes, 1800syme 1067foam 278name 259file 110type
Store 5380 K pool
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:
aldorbug Priority (1=urgent,..,9=detail): 8 Subject (brief description): Bad error msg compiling /etc/passwd Name of file with detailed description (default none): problem.rpt Please give the exact command line (example: 'aldor -Q3 file.as', say 'none' if is irrelevant): aldor /etc/passwd Source file demonstrating the bug: /etc/passwd Compiler version: v0.35.0 for AIX ESA
Fig 1.2: Aldor Ports
| Aldor Version | Processor | Operating System | Subordinate C Compiler |
| Unix derivatives | |||
| 1.1.12 linux | Intel i386 | Linux | GNU C |
| 1.1.12 rs4.1 | IBM RS/6000 | AIX 4.1 | IBM XLC |
| 1.1.12 sun4os4g | Sun Sparc | SunOS 4.1.x | GNU C |
| 1.1.12 sun4os55g | Sun Sparc | SunOS 5.5 | GNU C |
| 1.1.12 sun4os55c | Sun Sparc | SunOS 5.5 | SUNPRO |
| 1.1.12 irixmips1 | MIPS I | IRIX 5 | MIPS C |
| 1.1.12 irixmips3 | MIPS III | IRIX 6 | MIPS C |
| 1.1.12 hpux | HP | HP/UX 10 | HP C |
| 1.1.12 axposfl v4 | DEC Alpha | OSF/1(V4.0) | DEC C |
| 1.1.10 sun4os4c | Sun Sparc | SunOS 4.1.x | Sun C (K&R) |
| 1.00.6 rsgcc | IBM RS/6000 | AIX 3.2 | GNU C |
| 0.33.0 aixrt | IBM RT/PC | AIX 2.2 | IBM C (K&R) |
| 0.35.0 aixesa | IBM S/370 | AIX/ESA | Metaware C |
| 0.33.5 next | Motorola 680x0 | Next Mach | GNU C |
| DOS, Windows | |||
| 0.28.0 dosbcc | Intel i386 (16 bit) | DOS 5.0 | Borland C++ |
| 1.00.0 dosgcc | Intel i386 (32 bit) | Dos 5.0 Windows 3.1 | GNU C |
| OS/2 | |||
| 0.23.0 os2cset2 | Intel i386 | OS/2 2.0 | IBM C Set 2 |
| 0.28.0 os3bcc | Intel i386 | OS/2 2.0 | borland C++ |
| Macintosh | |||
| 0.36.0 macsys7 | Motorola 680x0 | System 7 | * |
| * macppx | Power PC | System 7 | Metrowerks C |
| Others | |||
| 0.31.0 cms | IBM S/370 | VM/CMS | C 370 |
| * vmsaxp | DEC a AXP | VMS | DEC C |
* in progress
Entries in this table do not imply commercial availability.
Home
Contents
Next