[Aldor-l] non-constant constants was: Re: [Axiom-developer] Re: exports and constants
Ralf Hemmecke
ralf at hemmecke.de
Sat Jul 29 01:43:05 EDT 2006
Hi Bill,
>> I turned exports into a function, as you'd probably want to
>> call it more than once.
> I don't understand the relevance of whether exports is a function
> or not. As a generator we can use it as often as we like. No?
Try the following piece of code.
---BEGIN aaa14.as
#include "aldor"
#include "aldorio"
main(): () == {
import from Integer, List Integer;
fun(): Generator Integer == generate {
yield 0;
yield 1;
};
const: Generator Integer == fun();
stdout << [fun()] << newline;
stdout << [fun()] << newline;
stdout << [const] << newline;
stdout << [const] << newline;
}
main();
---END aaa14
>aldor -grun -laldor aaa14.as
[0,1]
[0,1]
[0,1]
[]
I agree that const is not constant. But a Generator is inherently
destructive.
If you like you could also say something like
a: Record(x: Integer) == [1];
a.x := 0;
and the "constant" a changes. But you should note that the last line is
actually
set!(a, x, 0)
so that is a destructive function and thus you should expect strange
things. The BANG functions (like set!) are only for people who know what
they do.
Ralf
More information about the Aldor-l
mailing list