axiom-developer
[Top][All Lists]
Advanced

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

Re: [Axiom-developer] RE: Tail recursion (what does")clear all" NOT do?)


From: William Sit
Subject: Re: [Axiom-developer] RE: Tail recursion (what does")clear all" NOT do?)
Date: Thu, 01 Sep 2005 02:56:19 -0400

I tried the simple tail recursion code by Bill, and repeat after )clear all,
with slight variations. Here are two transcripts. I also verify that if one
starts a FRESH session of Axiom, f and g behave symmetrically when lines (5) of
the FIRST trial are switched from f to g. Comments added in transcripts.

Transcript 1:
                        AXIOM Computer Algebra System
              Version of Tuesday November 30, 2004 at 21:11:14
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------

(1) -> )set mess autoload off
(1) -> )set functions compile on

Comments: Trial A:

(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> f(1)
   Compiling function g with type Integer -> Integer
(5) -> f(1)

   >> System error:
   The function |*1;f;1;initial| is undefined.

protected-symbol-warn called with (NIL)
(5) -> g(1)

   >> System error:
   The function |*1;f;1;initial| is undefined.

protected-symbol-warn called with (NIL)

Comments on Trial A: same as Bill's. Now Trial B.

(5) -> )clear all
   All user variables and function definitions have been cleared.
(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> g(1)
   Compiling function f with type Integer -> Integer
(5) -> f(2)

   >> System error:
   Invocation history stack overflow.

protected-symbol-warn called with (NIL)
(5) -> f(1)

   >> System error:
   Invocation history stack overflow.

protected-symbol-warn called with (NIL)

Comments on Trial B: why does f(2) make a difference? If the stack overflowed,
should it be cleared? If yes, computational result may be lost? Does an
overflowed stack still have any usefulness? If not (as it seems), will forcing a
user to exit Axiom cause loss of data (including previously computed results in
the same session if the user did not )spool? 
Now Trial C.

(5) -> )clear all
   All user variables and function definitions have been cleared.
(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> g(1)
   Compiling function f with type Integer -> Integer
(5) -> g(1)

   >> System error:
   Invocation history stack overflow.

protected-symbol-warn called with (NIL)

Comments on Trial C: why does g(1) make a difference? Could this be because
")clear all" does not clear all (such as the Invocation history stack? It does
not clear input history: is that the same?)

Transcript 2:
                        AXIOM Computer Algebra System
              Version of Tuesday November 30, 2004 at 21:11:14
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------


(1) -> )set mess autoload off
(1) -> )set functions compile on

Comments: Trial D, same as Trial A.

(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> f(1)
   Compiling function g with type Integer -> Integer
(5) -> f(1)

   >> System error:
   The function |*1;f;1;initial| is undefined.

protected-symbol-warn called with (NIL)

Comments on Trial D: none. Now Trial E.

(5) -> )clear all
   All user variables and function definitions have been cleared.
(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> f(1)
   Compiling function g with type Integer -> Integer

Comments on Trial E: The next )clear all was accidental. Now Trial F.

(5) -> )clear all
   All user variables and function definitions have been cleared.
(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> f(1)
   Compiling function g with type Integer -> Integer
(5) -> f(1)

   >> System error:
   The function |*1;f;1;initial| is undefined.

protected-symbol-warn called with (NIL)
(5) -> g(2)

   >> System error:
   The function |*1;f;1;initial| is undefined.

protected-symbol-warn called with (NIL)

Comments on Trial F: Why doesn't "Invocation Stack Overflow" occur in g(2)? as
in Trial B of Transcript 1? How was the symmetry in f and g broken? Does the
accident Trial E has anything to do with this?  Now Trial G, which repeats Trial
F.

(5) -> )clear all
   All user variables and function definitions have been cleared.
(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> f(1)
   Compiling function g with type Integer -> Integer
(5) -> g(2)

   >> System error:
   The function |*1;f;1;initial| is undefined.

protected-symbol-warn called with (NIL)

Comments on Trial G, a repeat of Trial F, no surprise. Now Trial H.

(5) -> )clear all
   All user variables and function definitions have been cleared.
(1) -> f:INT->INT
                                                                   Type: Void
(2) -> g:INT->INT
                                                                   Type: Void
(3) -> f(n)==g(n)
                                                                   Type: Void
(4) -> g(n)==f(n)
                                                                   Type: Void
(5) -> g(1)
   Compiling function f with type Integer -> Integer
(5) -> f(2)

   >> System error:
   Invocation history stack overflow.

protected-symbol-warn called with (NIL)
(5) ->

Comments on Trial H: This is the same as Trial F except in (5) g and f are
switched. symmetry broken again?

Final comments: Axiom should be consistent after a ")clear all", and f and g
should behave symmetrically. Moreover, using f(1) or f(2) should make no
difference to the error messages in the above code. And, of course, the first
call in (5) should already return an error message, as Bill noted already.

William




reply via email to

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