Jump to content

Aldor

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 82.33.172.215 (talk) at 23:27, 27 May 2014 (Added a dependent type example to answer the query on the Talk Page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Aldor
Paradigmmulti-paradigm: object-oriented, functional, imperative, dependent typed, logic programming
Designed byRichard Dimick Jenks, Barry Trager, Stephen Watt, James Davenport, Robert Sutor, Scott Morrison
DeveloperIBM Thomas J. Watson Research Center
PlatformAxiom computer algebra system
LicenseApache License
Filename extensions.al, .as
Websitewww.aldor.org
Major implementations
Axiom computer algebra system
Influenced by
A, Pascal, Haskell

Aldor is a programming language. It is the successor of A# as the extension language of the Axiom computer algebra system.

The Aldor language combines imperative, functional, and object-oriented features. It has an elaborate type system[citation needed], allowing types to be used as first-class values. Aldor's syntax is heavily influenced by Pascal, but it is optionally indentation-sensitive, like Python. In its current implementation, it is compiled, but an interactive listener is provided.

Aldor is Free software, available under the Apache License.

Examples

The Hello world program looks like this:

#include "aldor"
#include "aldorio"

stdout << "Hello, world!" << newline;

Example of dependent types (from the User Guide):

#include "aldor"
#include "aldorio"
#pile

sumlist(R: ArithmeticType, l: List R): R == 
    s: R := 0;
    for x in l repeat s := s + x
    s

import from List Integer, Integer, List SingleFloat, SingleFloat
stdout << sumlist(Integer, [2,3,4,5]) << newline
stdout << sumlist(SingleFloat, [2.0, 2.1, 2.2, 2.4]) << newline
99 Bottles of Beer
#include "aldor"
#include "aldorio"

import from Integer, String;

bob(n: Integer): String == {
    b: String := " bottle";

    if n ~= 1 then b := b + "s";
    b + " of beer";
}

main(): () == {
    n: Integer := 99;
    otw: String := " on the wall";

    -- refrain
    while n > 0 repeat {
        stdout << n << bob(n) << otw << ", " << n << bob(n) << "." << newline;
        stdout << "Take one down and pass it around, ";
        n := n - 1;
        if n > 0 then stdout << n;
        else stdout << "no more";
        stdout << bob(n) << otw << "." << newline;
        stdout << newline;
    }

    -- last verse
    stdout << "No more" << bob(n) << otw << ", no more" << bob(n) << "." << newline;
    stdout << "Go to the store and buy some more, ";
    n: Integer := 99;
    stdout << n << bob(n) << otw << "." << newline;
}

main();