[Aldor-l] Questions on Name constancy in type context and lazy evaluation

Martin Rubey martin.rubey at univie.ac.at
Tue Oct 31 02:53:31 EST 2006


Dear all,

I'm sending this mail not only to aldor-l, since I don't know whether it is
read by everybody, and because I try to make a fresh start.



Here is a summary of our discussion:

We have working code (for Aldor 1.02 and 1.03, all optimization settings) that
creates types at runtime, which may be recursively defined and mutually
dependent. For example,

grammar(["Plus(SingletonSpecies, Times(Self1, Self1))"])

returns a type equivalent to 

B: CombinatorialSpecies == Plus(SingletonSpecies, Times(B, B)) add;

Note the recursive definition of B. "SingletonSpecies" is a special instance of
"CombinatorialSpecies", "Plus" and "Times" are constructors taking
CombinatorialSpecies and returning one.

However, although the code is working, we believe that it is not conforming to
the Aldor language as described in the AUG. More precisely, we believe that
both name-constancy in type context is violated and we rely on a particular
order of evaluation of expressions in type context.

I would like to know, whether our belief is correct, and if so, whether there
is a "conforming" workaround, or, whether the section on type context in the
Aldor User Guide could be more precise about evaluation in type context and
name-constancy.

Consider the sequence of expression

--- Snippet 1 -----------------------------------------------------------------

1   a: PrimitiveArray MyType == new(1);
2   D: MyType == f(a) add;
3   a.0 := D;
4
5   a.0;
-------------------------------------------------------------------------------

Thus, we return something of type MyType, and we want it to be equivalent to
the expression  

   D: MyType == f(D) add;

However, we need something more general than the latter. Consider 

--- Snippet 2 -----------------------------------------------------------------

1   D: MyType; E: MyType;
2   D == f(D, E) add;
3   E == g(D, E) add;
-------------------------------------------------------------------------------

or

--- Snippet 3 -----------------------------------------------------------------

1   D: MyType; E: MyType; F: MyType;
2   D == f(D, E, F) add;
3   E == g(D, E, F) add;
4   F == h(D, E, F) add;
-------------------------------------------------------------------------------

All these examples are OK according to the Aldor User Guide. So, it should well
be possible to have a given list of functions f, g, h, ... that all take a list
of domains, and construct a corresponding number of domains D, E, F,
... correpondingly. That's exactly what the grammar code does. However,
according to the Aldor User Guide, the statement a.0 := D in line 3 of Snippet
1 violates name constancy, and we cannot be sure that f is evaluated only after
line 3 of the same code Snippet.

By the way, how can we know that f in Snippet 3 is avaluated after line 4?


Comments VERY welcome!

Martin



PS: And, ceterum censeo, it would be really NOTWENDIG (= necessary, but also in
the sense of turning neediness) to have free Aldor Sources. There are people
willing to work on them, PLEASE HELP US!




More information about the Aldor-l mailing list