axiom-developer
[Top][All Lists]
Advanced

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

non-constant constants was: Re: [Aldor-l] [Axiom-developer] Re: export


From: Ralf Hemmecke
Subject: non-constant constants was: Re: [Aldor-l] [Axiom-developer] Re: exports and constants
Date: Sat, 29 Jul 2006 07:43:05 +0200
User-agent: Thunderbird 1.5.0.5 (X11/20060719)

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




reply via email to

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