Aldor User Guide

35 views
Skip to first unread message

Martin

unread,
Nov 13, 2014, 3:31:48 AM11/13/14
to aldor...@googlegroups.com
In order to try out Peters program I picked some code at random from the Aldor User Guide here:
http://www.aldor.org/docs/HTML/chap2.html#4
Am I correct in thinking that this is the 'official' documentation for Aldor?
I happened to choose the 'MiniList' code.

I have copied the full program (+ Peters prefix) below.

When I saved the program (to compile it) it produced an error. I attempted to fix it (with my very limited experience of Aldor so my fixes may not be correct) and it produced another error and so on, here are my first few 'fixes':

-MiniList(S: BasicType): LinearAggregate(S) = add {
+MiniList(S: BasicType): LinearAggregate(S) == add {

-    (l1: %) = (12: %): Boolean == {
+    (l1: %) = (l2: %): Boolean == {

-        empty ? l1 and empty? l2
+        empty? l1 and empty? l2

In the end I gave up, am I doing something wrong or is the code full of typos?

Martin

The original code:
-----------------------------------------------------------

-- Include file for the aldorTest project.-- it is expected that it will be included in all source files that
-- make up this project.
--NOBUILD
#if BUILD_aldorTest
#else
#library aldorTest "libaldorTest.al"
#endif
#include "aldor"

MiniList(S: BasicType): LinearAggregate(S) = add {
        Rep == Union(nil: Pointer, rec: Record(first: S, rest: %));

        import from Rep, SingleInteger;

        local cons (s:S,l:%):% == per(union [s, l]);
        local first(l: %): S   == rep(l).rec.first;
        local rest (l: %): %   == rep(1).rec.rest;

        empty (): %            == per(union nil);
        empty?(l: %):Boolean   == rep(1) case nil;
        sample: %              == empty();

        [t: Tuple S]: % == {
                l := empty();
        for i in length t..1 by -1 repeat
               l := cons(element(t, i), l);
                l
        }
    [g: Generator S]: % == {
                r := empty(); for s in g repeat r := cons(s, r);
        l := empty(); for s in r repeat l := cons(s, l);
        l
        }
    generator(l: %): Generator S == generate {
            while not empty? l repeat {
                yield first l; l := rest l
                }
        }
    apply(l: %, i: SingleInteger): S == {
            while not empty? l and i > 1 repeat
                (l, i) := (rest l, i-1);
        empty? l or i ~= 1 => error "No such element";
        first l
    }
    (l1: %) = (12: %): Boolean == {
            while not empty? l1 and not empty? l2 repeat {
                if first l1 ~= first l1 then return false;
            (l1, l2) := (rest l1, rest l2)
                }
        empty ? l1 and empty? l2
        }
    (out: TextWriter) << (l: %): TextWriter == {
                empty? l => out << "[]";
        out << "[" << first l;
        for s in rest l repeat out << ", " < s;
        out << "]"
        }
}

Peter Broadbery

unread,
Nov 13, 2014, 4:33:42 AM11/13/14
to Martin, aldor...@googlegroups.com
Hi,

I'm assuming this is two files - the include up to the endif and a new
file after that -- anything marked '--NOBUILD' won't be built. The
rationale for the include to avoid having the boiler plate library
stuff in every file.

Anyway, looking at the user guide (I don't have write access to the
site, so I can't change the background....) the file isn't right -
it's using names from the older axllib library, and seems to have been
copied badly..

This is fairly close to a running program - not tested for correctness though.

#include "qqq.as"

#include "aldor"
#include "aldorio"

MiniList(S: Type): LinearStructureType(S) with {
if S has OutputType then OutputType }
== add {
Rep == Union(nil: Pointer, rec: Record(first: S, rest: %));

import from Rep, MachineInteger;

local cons (s:S,l:%):% == per(union [s, l]);
local first(l: %): S == rep(l).rec.first;
local rest (l: %): % == rep(l).rec.rest;

empty (): % == per(union(nil$Pointer));
empty?(l: %):Boolean == rep(l) case nil;

[g: Generator S]: % == {
r := empty(); for s in g repeat r := cons(s, r);
l := empty(); for s in r repeat l := cons(s, l);
l
}

firstIndex: MachineInteger == 0;
free!(l: %): () == return; -- Should really be something here
set!(l: %, n: MachineInteger, s: S): S == never;

generator(l: %): Generator S == generate {
while not empty? l repeat {
yield first l; l := rest l
}
}

apply(l: %, i: MachineInteger): S == {
while not empty? l and i > 1 repeat
(l, i) := (rest l, i-1);
empty? l or i ~= 1 => error "No such element";
first l
}

if S has PrimitiveType then {
(=)(l1: %, l2: %): Boolean == {
while not empty? l1 and not empty? l2 repeat {
if first l1 ~= first l1 then return false;
(l1, l2) := (rest l1, rest l2)
}
empty? l1 and empty? l2
}
equal?(l1: %, l2: %, n: MachineInteger): Boolean == {
zero? n => true;
first l1 ~= first l2 => false;
equal?(rest l1, rest l2, n-1);
}
}
if S has OutputType then {
> --
> You received this message because you are subscribed to the Google Groups
> "aldor-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to aldor-devel...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Martin Baker

unread,
Nov 13, 2014, 5:46:31 AM11/13/14
to aldor...@googlegroups.com
On 13/11/14 09:33, Peter Broadbery wrote:
> Anyway, looking at the user guide (I don't have write access to the
> site, so I can't change the background....) the file isn't right -
> it's using names from the older axllib library, and seems to have been
> copied badly..

I think there are a lot of improvements that would be useful for the
person controlling the User Guide to make. Apart from the typos in
program listings I think the instructions for running Aldor need to be
updated (remove references to ALDORROOT for example). It would also be
useful to have instructions for building from source, feel free to use
my notes here:
http://www.euclideanspace.com/prog/scratchpad/aldor/install/

Martin

Peter Broadbery

unread,
Nov 13, 2014, 5:55:29 AM11/13/14
to Martin Baker, aldor...@googlegroups.com
The user guide is part of the github distribution, so we can change
that. (it might not work at the moment - I have to plead the usual
lack of time). The aldor.org website does need a refresh - not
exactly sure who's hosting it at the moment.

Peter

Ralf Hemmecke

unread,
Nov 13, 2014, 6:18:18 AM11/13/14
to aldor...@googlegroups.com
On 11/13/2014 11:55 AM, Peter Broadbery wrote:
> The user guide is part of the github distribution, so we can change
> that.

There is no "github distribution". It's just Pippijn's repository.
(Although I know that Pippijn was careful with the license stuff.)
Anyway the authorative place to look at is http://www.aldor.org/ where
it says:

We provide the development version on an as-is basis, under the
Apache Software Foundation Apache License, Version 2.0.

together with a link to http://www.aldor.org/distrib/Aldor-2013.tgz
(which also contains the Aldor user guide). This gives the right to edit
the AUG under the terms of the Apache License, Version 2.0.

> it might not work at the moment

On my computer "cd aldor/aldorug; make" works fine and produces a file
aldorug.pdf.

Stephen Watt is the owner of aldor.org. But I don't think a lot of
people still think that this website is maintained. It's probably better
to create an own website for the open-source development.

Unfortunately, https://github.com/aldor is already taken.

Ralf

Waldek Hebisch

unread,
Nov 13, 2014, 6:24:32 AM11/13/14
to aldor...@googlegroups.com
Martin wrote:
>
> In order to try out Peters program I picked some code at random from the
> Aldor User Guide here:
> http://www.aldor.org/docs/HTML/chap2.html#4
> Am I correct in thinking that this is the 'official' documentation for
> Aldor?
> I happened to choose the 'MiniList' code.
>
> I have copied the full program (+ Peters prefix) below.
>
> When I saved the program (to compile it) it produced an error.
<snip>
>
> In the end I gave up, am I doing something wrong or is the code full of
> typos?

Yes, the code is full of typos. They look like typical OCR errors.
I am affraid that documentation at www.aldor.org was made via
OCR-ing a paper copy (or maybe you unintantinaly "pasted" the code
came via OCR).

--
Waldek Hebisch
heb...@math.uni.wroc.pl

Ralf Hemmecke

unread,
Nov 13, 2014, 6:57:07 AM11/13/14
to aldor...@googlegroups.com
On 11/13/2014 12:24 PM, Waldek Hebisch wrote:
> Yes, the code is full of typos. They look like typical OCR errors.
> I am affraid that documentation at www.aldor.org was made via
> OCR-ing a paper copy (or maybe you unintantinaly "pasted" the code
> came via OCR).

I don't believe it's OCR that makes for all the problems. Wild
speculation rather suggests that the HTML pages where made via some tool
from an earlier (or at least different) version of the .tex files that
produce the PDF version of the AUG.

I'd suggest to ignore the HTML version or at least only cite it if it
agrees with the corresponding part of
http://www.aldor.org/docs/aldorug.pdf .

Ralf

Peter Broadbery

unread,
Nov 13, 2014, 9:39:16 AM11/13/14
to Ralf Hemmecke, aldor...@googlegroups.com
By 'github distribution I merely meant the code on github that is
likely to work with the eclipse plugin. No more than that.

Disappointingly, scryer is taken too. But in any case I've no
complaints about how github (and Pippijn) is hosting stuff.

Peter
Reply all
Reply to author
Forward
0 new messages