axiom-developer
[Top][All Lists]
Advanced

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

[Axiom-developer] RE: [Aldor-l] exports and constants


From: Bill Page
Subject: [Axiom-developer] RE: [Aldor-l] exports and constants
Date: Mon, 24 Jul 2006 11:14:04 -0400

On July 24, 2006 3:38 AM Christian Aistleitner
> On Sun, 23 Jul 2006 08:00:56 +0200, Bill Page wrote:
> ...
> >> X: CatX == if odd? random(10) then A else B;
> ...
> > ...
> >   main(): () == {
> >     import from X;
> >     stdout << foo() << newline;
> >     stdout << foo() << newline;
> >     stdout << foo() << newline;
> >     stdout << foo() << newline;
> >     stdout << foo() << newline;
> >     stdout << foo() << newline;
> >   }
> >   main();
> >
> > You will see that each time you run the program you will only
> > get one *constant* result (all 0's or all 1's). But if you run
> > the same program repeatedly (as you did above), then sometimes
> > you get one result and sometimes the other! Within a given
> > runtime of the program, the result is constant and not variable
> > as you might be expecting.
> 
> I'd strongly expect it to be constant at runtime! "==" gives 
> a constant. So it should be constant. What kind of concept is a
> modifyable constant? Maybe you want to refer to a macro instead
> of a constant?

I agree with you and that was precisely my point. Perhaps I did
not explain myself clearly.

> 
> I assume that each time you start the program, odd? random(10)
> is evaluated exactly once. Of course, your whole main function
> accounts for exactly one program start.

Yes, howerver originally I believed that Aldor could resolve all
constant values at compile time. In retrospect that does not make
much sense and so it seems that (as in most other languages) the
values of constants in Aldor are initialized at run time.

> 
> > My conclusion is that Aldor must be sort of "faking" the
> > compilation of the constants in the sense that they are not
> > fully resolved at compile-time, yet they are indeed constant
> > within any run of the program. There must be some kind of
> > dynamic initialization phase at the start of the program.
> 
> I doubt that.

You doubt that?? Perhaps I should not have used the word "faking"
because in fact as you say below this is exactly what most
programming languages do.

> The constant X is compiled to "if odd? random(10) then A  
> else B;" and neither A nor B. That's not faking, that's just 
> what's in the .as file. However, the value of a constant is
> (typically) determined only once, hence for the whole program
> execution X acts like either A or B.
> 

I agree.

Regards,
Bill Page.






reply via email to

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