NAME
       d4 - an interpreted, interactive, array processing language.

SYNOPSIS
       d4x script {arguments}

DESCRIPTION

    D4 is an interpreted, interactive, array processing language based
on K.Iverson's APL[1], one of the world's first object oriented languages.
D4 is essentially a small subset of APL with ASCII workspaces, and a
UNIX style file system that allows any file to be treated like a
byte-vector. The name D4 comes from 4-Dimension which is a translation of
MITITISI, a Thai science fiction magazine. All versions are meant to
work on legacy computers running DOS, WINDOWS or LINUX. In particular
a 16-bit version is available (d4t.exe). The first version, written
in compiled BASIC, was run at computer show in the Hyatt-Plaza Hotel,
in Bangkok, Thailand. The C version was developed in Riyadh, Saudi
Arabia. Much of the current source code is unchanged from that time.

    The functions of the interpretor and scripts are carefully separated
on a 'Need to Know' basis. Keywords have been kept to a minimum, with
lower case letters being used for the traditional APL symbols.

    The key design objective of the interpretor is to handle real
economic and statistical problems arising from globalisation. There
is a script which will compute the Banzhaf Power index for European
Union voting system, by brute force, faster than C program using
Monte-Carlo simulation (http://d4maths.lowtech.org/eu2000.htm).

COMMAND LINE OPTIONS

    d4x S=val N=val W=val F=val k={value} i={value} script {options}

    If no script is available, the program looks for a file called
init.afn in the current directory.

    The variables N, S, W, F have the following meanings and defaults.

        S,s     stack size              512

        N,n     names                   512

        W,w     windows                  50

        F,f     file descriptors         32

        K,k     if defined, startup in input mode.
                Don't try and load init.afn..

        I,i     if defined supress break-in checking.
                For use in batch files.

    All other options must be processed by the script.

    The normal startup line is:-

    d4x filename {options} {var=value}


INTERPRETOR INTERFACE

    It is possible to run the interpretor (d4x) from the keyboard.
On UNIX systems it is possible to run scripts via a startup line:-

#!/usr/bin/d4x

    The interpretor can be run in raw input mode, and this is the
default behaviour in case of errors. It is much more convenient
to run a script which traps errors and runs a UNIX lookalike shell
with aliases and command line history. The interpretor is designed to
scan for functions and data definitions in any file.

    D4 scripts share some features with Python: spaces and line breaks
are important. The interpretor reads functions and data from the script
and then attempts to run the first non commented line of the script.
Blank lines separate objects. Objects themselves may contain blank lines
if they are defined as "here documents" as in Perl or the Bourne Shell.
The use of tab characters in scripts is depreciated.

    Unlike most other languages the line input routine consists of
a built in editor. This requires the user to have access to a DOS prompt
or a Linux terminal. Keyboard layout and character composition are
handled via tables kept by the interpretor. The editor can handle
both Hebrew from right to left and English from left to right.

    Scripts can handle standard arguments by methods similar to
most others: positional arguments are represented by $0, $1, $2...
and name=value pairs are treated by putting the names and values
in the main symbol table. Most scripts are meant to run exactly
the same on Windows and Linux. The D-shell scripts are supposed to
detect the environment and define the appropriate functions and
aliases.

    The interpretor handles math error signals and the interrupt
(break-in) key.

FILES AND DIRECTORIES

    These are in different places for different installations.
    d4x         Interpretor file
    dsh         Ascii file for local startup script.
    dsh.afn     D-shell script and commonly required objects.
    test.afn    Alternative D-shell
    d4s.lst     Current aliases
    *.d4f       various packages

    If d4x and dsh are placed in /usr/bin the D4 may be used for CGI
scripts.

ENVIRONMENT VARIABLES

    These are passed to the script in a virtual array called $ENVP[].

INSTALLATION

    Download math2546.tgz and etc.tgz for linux, and DNA.EXE (or RNA.EXE)
and CSRC.TGZ for DOS/WINDOWS. DNA.EXE and RNA.EXE are self extracting
programs. The linux version math2546.tgz contains source code which needs
to be compiled.

AUTHOR

       Tony Goddard
       email: tony@lowtech.org
       info:  447944764312

INTERNET RESOURCES
       http://d4maths.lowtech.org

LICENCING

       See the Gnu Public Licence.

[1] Kenneth Iverson trained as an economist. He invented APL in the
1950s. The most important features of APL included vector and tensor
operations on numbers. Iverson's work is particularly important in
the development of intereactive computing. APL preceded BASIC as a
language designed to help non computer specialists get results quickly
from the computer via an intereactive terminal. At that time many
terminals were hard copy terminals so the brevity of the APL notation
was a distinct advantage.














