axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex do


From: Ralf Hemmecke
Subject: [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains.
Date: Fri, 12 May 2006 14:19:19 +0200
User-agent: Thunderbird 1.5.0.2 (X11/20060420)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]