axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] Lazy re-evaluation (was: More AxiomUI)


From: Page, Bill
Subject: RE: [Axiom-developer] Lazy re-evaluation (was: More AxiomUI)
Date: Thu, 23 Jun 2005 00:50:36 -0400

On Wednesday, June 22, 2005 11:55 PM Andrey G. Grozin wrote:

> ...
> Only the user can decide *which* consistent state [s]he wants.
> Suppose there is a code fragment:
>
>   (1)   n:=1
>   (2)   x:=f(n)
>   (3)   n:=2
>   (4)   y:=f(n)
>
> Do you consider the state of Axiom after it inconsistent?
> I don't. This is an imperative language, after all.

I agree with you. The state of Axiom after executing this just
this sequence of commands would be consistent by definition.
"Consistent" means that the commands have been executed in the
order implied by their appearance on the page. I have added line
numbers such as (2) for reference.

Let's assume that f is defined as:

(0)  f:=operator 'f

   (0)  f
                                         Type: BasicOperator

then here is an actual example from Axiom:

(1) -> n:=1

   (1)  1
                                         Type: PositiveInteger
(2) -> x:=f(n)

   (2)  f(1)
                                         Type: Expression Integer
(3) -> n:=2

   (3)  2
                                         Type: PositiveInteger
(4) -> y:=f(n)

   (4)  f(2)
                                         Type: Expression Integer

(5) -> )display values
   Value of f: BasicOperator:  f
   Value of n: PositiveInteger:  2
   Value of x: Expression Integer:  f(1)
   Value of y: Expression Integer:  f(2)

The state of the computation is given by the output of the
)display command

> If the user edits the first line to read:
>
> (1)   n:=3
>

As soon as the user edits the first line, the current contents
of the page displayed page is no longer consistent with the
the current state of Axiom. In order to restore consistency
it is necessary to "roll-back" the sequence of calculations
and repeat some of the previously executed commands again,
beginning in this case is the first (1).

> and then re-executes the second line,

Yes I agree the second line (2) must be re-evaluated. Line
(3) will also have to be repeated because we have destroyed
the expected value of n by executing the revised line (1)
and it's old value must now be restored.

> are you sure the user wants to re-execute the fourth line
> too? I am not.

I agree with you. The fourth line (4) does not have to be
re-executed. It depends only on the value that n had when (3)
was first executed and n still has the value. So Axiom only
has to do the following:

(1) -> n:=3

   (1)  3
                                          Type: PositiveInteger
(2) -> x:=f(n)

   (2)  f(3)
                                           Type: Expression Integer
(3) -> n:=2

   (3)  2
                                           Type: PositiveInteger

(5) -> )display values
   Value of f: BasicOperator:  f
   Value of n: PositiveInteger:  2
   Value of x: Expression Integer:  f(3)
   Value of y: Expression Integer:  f(2)

And now the state of Axiom is consistent with the appearance of
the page again.

> I'd hate it if the system would make such decisions for me.

I don't understand. This is exactly the same decision that
you just said that you would have made.

Regards,
Bill Page.




reply via email to

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