Christian,

To underpin, that the given Dom is a function, look at the attached test.as file. It gives you a a domain in the usual domain syntax and the usual function syntax. Introducing DomVar in the variant is necessary, sinc the compiler causes troubles otherwise. But i'd consider that a compiler problem.

Christian is right the following

f(a: A): B == ...

is just syntactic sugar for defining a constant.

f: (a: A) -> B == (a: A): B +-> ...

That is explained in Section 6.5 of http://www.aldor.org/docs/aldorug.pdf

But let's look at Christian's code again. This is now slightly modified.
As you realise from the output, the domain Dom(0) is instantiated only once. But this is in accordance to the specification in Section 7.3 of the Aldor User Guide. And thus Dom behaves functional.

Maybe it is possible to instantiate Dom(0) twice. I don't have an example yet. An anyway this only explains what the compiler does and not whether the language specifies a "functional type (sub-)language".

Ralf

--Domtest.as
#include "aldor"
import from Integer;
import from TextWriter, String, Character;

Dom( a: Integer ): with {
    f: () -> Integer
} == {
        import from RandomNumberGenerator, MachineInteger;
        stdout << "Dom " << a << ": " << randomInteger() << newline;
        add {f(): Integer == { next a }}
}

stdout << f()$Dom(0) << newline;
stdout << f()$Dom(0) << newline;

#if OUTPUT
>aldor -grun -laldor -mno-mactext Domtest.as
#1 (Warning) The file `Domtest' will now be out of date.
Dom 0: 1107506637
1
1
#endif


_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to