login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for #378 Declarations with multiple variables don't work inside of functions revision 1 of 3

1 2 3
Editor:
Time: 2007/11/17 22:34:48 GMT-8
Note: typos

changed:
-
The syntax for declarations which have multiple variables is given
on page 142 of the Axiom book.  However, using this syntax inside
a function results in the compiler failing.

The first time an attempt is made to compile a function which uses
this syntax, no diagnostic is produced.  However, the libraries
needed by the function being compiled are not loaded, and the
function itself is not executed (or at least it doesn't produce
any output).  If a second attempt is made to execute the function,
a "System error" results.

The following session transcript demonstrates the problem.  It
attempts to execute two functions.  The first of these, named "bug",
demonstrates the behavior described above.  The second function,
named "nonbug", is identical to "bug" except that the declaration
containing two variables has been replaced by two declarations
each containing a single variable.  Axiom handles the "nonbug"
function correctly, demonstrating that the problem is triggered
by a declaration containing multiple variables.  The transcript
follows:


<pre>
$ axiom
                        AXIOM Computer Algebra System 
                         Version: Axiom (April 2006)
               Timestamp: Wednesday June 21, 2006 at 03:45:56 
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------
 
   Re-reading compress.daase   Re-reading interp.daase
   Re-reading operation.daase
   Re-reading category.daase
   Re-reading browse.daase
(1) -> 
(1) -> bug(x) == (local a, b; (a, b) : Integer; 1)
                                                                   Type: Void
(2) -> bug(1)
   Compiling function bug with type PositiveInteger -> PositiveInteger 
(2) -> bug(1)
 
   >> System error:
   (|Tuple| |a| |b|) is not of type SYMBOL.

(2) -> nonbug(x) == (local c, d; c : Integer; d : Integer; 1)
                                                                   Type: Void
(3) -> nonbug(1)
   Compiling function nonbug with type PositiveInteger -> 
      PositiveInteger 

   Loading /home/ka/w/axiom/mnt/linux/algebra/PI.o for domain 
      PositiveInteger 
   Loading /home/ka/w/axiom/mnt/linux/algebra/NNI.o for domain 
      NonNegativeInteger 
   Loading /home/ka/w/axiom/mnt/linux/algebra/INT.o for domain Integer 
   Loading /home/ka/w/axiom/mnt/linux/algebra/OUTFORM.o for domain 
      OutputForm 
   Loading /home/ka/w/axiom/mnt/linux/algebra/LIST.o for domain List 
   (3)  1
                                                        Type: PositiveInteger
(4) -> )quit
</pre>


From wyscc Sat Sep 8 14:37:53 -0500 2007
From: wyscc
Date: Sat, 08 Sep 2007 14:37:53 -0500
Subject: (a,b):Integer is incorrect syntax
Message-ID: <20070908143753-0500@wiki.axiom-developer.org>

I tried:

\begin{axiom}
nobug(x) == (local a, b; a, b : Integer; a:=b:=1; a+b)
nobug(1)
bug(x) == (local a, b; (a, b) : Tuple Integer; a:=b:=1; a+b)
bug(1)
\end{axiom}

Also, when I tried this in my Windows version, I got:

<pre>
                        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) -> bug(x) == (local a, b; (a, b) : Integer; 1)
                                                                   Type: Void
(2) ->   bug(1)
   Compiling function bug with type PositiveInteger -> PositiveInteger

   >> System error:
   (|Tuple| |a| |b|) is not of type SYMBOL.

protected-symbol-warn called with (NIL)
</pre>

So the older version caught the syntax error on first compile and run. Your example seems to me to be a syntax error that was not caught in the current version on first compile and run (I was not able to find the '(a,b):Integer' in the Axiom book.) since '(a,b)' is a tuple. Correct syntax is 'a, b:Integer' for multivariable declarations. Note that '(a,b):Tuple Integer' is incorrect syntax also, since '(a,b)' is not an indentifier.

From wyscc Sat Sep 8 15:01:34 -0500 2007
From: wyscc
Date: Sat, 08 Sep 2007 15:01:34 -0500
Subject: "(a,b):Integer" vs "a, b:Integer"
Message-ID: <20070908150134-0500@wiki.axiom-developer.org>

Seems like '(a,b):Type' is syntactic sugar in the interpreter and 'a,b:Type' does not define type of 'a' correctly (but 'b' is typed correctly; probably the reason to require parenthesis---this requires the interpreter parser to distinguish '(a,b)' to the left of : from to the right of : ). So this is another inconsistency between interpreter and compiler, or this may be due to an original bug or an unknown difficulty in parsing the comma separator in the interpreter. Alternatively, if the *compiler* manual says '(a,b):Type' should be okay, then it is a compiler bug and the workaround is to use 'a,b:Type'.

\begin{axiom}
(a,b):POLY INT
a:= 11
typeOf a
b:= 12
a+b
c,d:POLY INT
c:=11
d:=12
c+d
\end{axiom}

Why does 'c,d:POLY INT' produce a Lisp output? and of type 'Tuple Void'?

Submitted by : (unknown) at: 2007-11-17T22:34:48-08:00 (16 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

The syntax for declarations which have multiple variables is given on page 142 of the Axiom book. However, using this syntax inside a function results in the compiler failing.

The first time an attempt is made to compile a function which uses this syntax, no diagnostic is produced. However, the libraries needed by the function being compiled are not loaded, and the function itself is not executed (or at least it doesn't produce any output). If a second attempt is made to execute the function, a "System error" results.

The following session transcript demonstrates the problem. It attempts to execute two functions. The first of these, named "bug", demonstrates the behavior described above. The second function, named "nonbug", is identical to "bug" except that the declaration containing two variables has been replaced by two declarations each containing a single variable. Axiom handles the "nonbug" function correctly, demonstrating that the problem is triggered by a declaration containing multiple variables. The transcript follows:

$ axiom
                        AXIOM Computer Algebra System 
                         Version: Axiom (April 2006)
               Timestamp: Wednesday June 21, 2006 at 03:45:56 
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------

Re-reading compress.daase Re-reading interp.daase Re-reading operation.daase Re-reading category.daase Re-reading browse.daase (1) -> (1) -> bug(x) == (local a, b; (a, b) : Integer; 1) Type: Void (2) -> bug(1) Compiling function bug with type PositiveInteger -> PositiveInteger (2) -> bug(1)

>> System error: (|Tuple| |a| |b|) is not of type SYMBOL.

(2) -> nonbug(x) == (local c, d; c : Integer; d : Integer; 1) Type: Void (3) -> nonbug(1) Compiling function nonbug with type PositiveInteger -> PositiveInteger

Loading /home/ka/w/axiom/mnt/linux/algebra/PI.o for domain PositiveInteger Loading /home/ka/w/axiom/mnt/linux/algebra/NNI.o for domain NonNegativeInteger Loading /home/ka/w/axiom/mnt/linux/algebra/INT.o for domain Integer Loading /home/ka/w/axiom/mnt/linux/algebra/OUTFORM.o for domain OutputForm Loading /home/ka/w/axiom/mnt/linux/algebra/LIST.o for domain List (3) 1 Type: PositiveInteger (4) -> )quit

(a,b):Integer is incorrect syntax --wyscc, Sat, 08 Sep 2007 14:37:53 -0500 reply
I tried:

axiom
nobug(x) == (local a, b; a, b : Integer; a:=b:=1; a+b)
Type: Void
axiom
nobug(1)
axiom
Compiling function nobug with type PositiveInteger -> Integer
LatexWiki Image(1)
Type: PositiveInteger?
axiom
bug(x) == (local a, b; (a, b) : Tuple Integer; a:=b:=1; a+b)
Type: Void
axiom
bug(1) Cannot convert right-hand side of assignment 1 to an object of the type Tuple Integer of the left-hand side.

Also, when I tried this in my Windows version, I got:

                        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) -> bug(x) == (local a, b; (a, b) : Integer; 1) Type: Void (2) -> bug(1) Compiling function bug with type PositiveInteger -> PositiveInteger

>> System error: (|Tuple| |a| |b|) is not of type SYMBOL.

protected-symbol-warn called with (NIL)

So the older version caught the syntax error on first compile and run. Your example seems to me to be a syntax error that was not caught in the current version on first compile and run (I was not able to find the (a,b):Integer in the Axiom book.) since (a,b) is a tuple. Correct syntax is a, b:Integer for multivariable declarations. Note that (a,b):Tuple Integer is incorrect syntax also, since (a,b) is not an indentifier.

"(a,b):Integer" vs "a, b:Integer" --wyscc, Sat, 08 Sep 2007 15:01:34 -0500 reply
Seems like (a,b):Type is syntactic sugar in the interpreter and a,b:Type does not define type of a correctly (but b is typed correctly; probably the reason to require parenthesis---this requires the interpreter parser to distinguish (a,b) to the left of : from to the right of : ). So this is another inconsistency between interpreter and compiler, or this may be due to an original bug or an unknown difficulty in parsing the comma separator in the interpreter. Alternatively, if the compiler manual says (a,b):Type should be okay, then it is a compiler bug and the workaround is to use a,b:Type.

axiom
(a,b):POLY INT
Type: Void
axiom
a:= 11
LatexWiki Image(2)
Type: Polynomial Integer
axiom
typeOf a
LatexWiki Image(3)
Type: Domain
axiom
b:= 12
LatexWiki Image(4)
Type: Polynomial Integer
axiom
a+b
LatexWiki Image(5)
Type: Polynomial Integer
axiom
c,d:POLY INT LISP output: (() ())
Type: Tuple Void
axiom
c:=11
LatexWiki Image(6)
Type: PositiveInteger?
axiom
d:=12
LatexWiki Image(7)
Type: Polynomial Integer
axiom
c+d
LatexWiki Image(8)
Type: Polynomial Integer

Why does c,d:POLY INT produce a Lisp output? and of type Tuple Void?