Template:Short description Template:More citations needed

Template:Infobox programming language Aldor is a programming language.<ref name="Gerdt2010">Template:Cite book</ref><ref name="Kirchner2006">Template:Cite book</ref><ref name="Kerber2001">Template:Cite book</ref> It is the successor of A# as the extension language of the Axiom computer algebra system.

Aldor combines imperative, functional, and object-oriented features. It has an elaborate type system,<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> allowing types to be used as first-class values. Aldor's syntax is heavily influenced by Pascal, but it is optionally indentation-sensitive, using whitespace characters and the off-side rule, like Python. In its current implementation, it is compiled, but an interactive listener is provided.

Aldor is distributed as free and open-source software, under the Apache License 2.0.

ExamplesEdit

The Hello world program looks like this: <syntaxhighlight lang="cpp">

  1. include "aldor"
  2. include "aldorio"

stdout << "Hello, world!" << newline; </syntaxhighlight>

Example of dependent types (from the User Guide): <syntaxhighlight lang="haskell">

  1. include "aldor"
  2. include "aldorio"
  3. 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 </syntaxhighlight>

99 Bottles of Beer: <syntaxhighlight lang="haskell">

  1. include "aldor"
  2. 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(); </syntaxhighlight>

ReferencesEdit

Template:Reflist

External linksEdit


  1. REDIRECT Template:Prog-lang-stub

Template:R shell