axiom-developer
[Top][All Lists]

## Re: [Axiom-developer] Aldor and Lisp

 From: Peter Broadbery Subject: Re: [Axiom-developer] Aldor and Lisp Date: Tue, 18 Oct 2005 20:20:59 +0100

```On Tue, 2005-10-18 at 10:40 -0400, Camm Maguire wrote:
> Greetings!
>
>
> > On Sat, 2005-10-15 at 11:10 +0200, Martin Rubey wrote:
> > > Dear Camm, Cliff, *,
> > >
> >
> > If there's a rewrite of Spad using a little more of aldor, then I'd also
> > be interested in helping occasionaly (unless a really freely available
> > Aldor comes along).
> >
> > > There are some other small differences, I don't know by heart.
> > >
> > > -------------------------------------------------------------------------------
> > >
> >
> > I guess you've missed generators, exceptions (implemented late, and IMHO
> > badly), and a very strong code optimisation phase.
> >
>
> Thank you so much for this.  If you have time, it would be msot
> helpful to give a brief example showing how each of these enhancements
> works.
>

Generators let you say '[f(x) for x in someCollection()]' in types other than
the pre-defined axiom ones.  The type Generator represents a possibly unbounded
sequence
of values (like Stream, but with less baggage).  The form 'for x in E'
represents
iteration over the stream, and the bracket function collects the values
together.
If you look in axextend.as there should be some real examples.

A rather pointless example would be
generator(x: Integer): Generator Integer == generate { yield x; yield
x+1 }

[x+100 for x in 22] -- will return a list containing 122 and 123.

The first line is a stream of 2 values, the second iterates over it (the
'generator' function is implicitly called on the target of a for loop).
axextend.as contains many more useful examples.

Exceptions are try and catch blocks in C++/java terms, or catch and
throw in lisp. An example will take too long, I think..

The optimiser's main jobs are to try to inline definitions of functions
and unwind generator uses.

Function inlining is important since axiom's types tend to have several
layers of representations.  A function inliner will peel back the
layers, so that for example, a test for zero in POLY will wind up being
a simple test against null.

Peter

> >
>

```