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. ----------------------------------------------------------------------------- axiom nobug(x) == (local a, Type: Voidaxiom nobug(1) axiom Compiling function nobug with type PositiveInteger -> Integer
Type: PositiveIntegeraxiom bug(x) == (local a, Type: Voidaxiom bug(1) 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. ----------------------------------------------------------------------------- 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):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, Type: Voidaxiom a:= 11
Type: Polynomial(Integer)axiom typeOf a
Type: Typeaxiom b:= 12
Type: Polynomial(Integer)axiom a+b
Type: Polynomial(Integer)axiom c, Type: Tuple(Void)axiom c:=11
Type: PositiveIntegeraxiom d:=12
Type: Polynomial(Integer)axiom c+d
Type: Polynomial(Integer)Why does axiom c, Type: Tuple(Void)is a tuple, consisting of a symbol `c' and a declaration `d: POLY INT'. However, a declaration has type `Void', and since a Tuple is a homogeneous container, both component must be brought to a common type, which is `Void'. Thus we get a Tuple Void. But, a `Void' is not coercible to OutputForm, therefore we get the LISP output. Try axiom 2,
Type: Tuple(PositiveInteger)My preference would be that we reject the declaration `(a,b): Integer' - which is invalid based on the above explanation. And we also reject `(a,b): Tuple Integer' because, if we do accept it, then we should logically -- for consistency -- accept `(a,b): Tuple Integer := tupleExpression'. But we have, in general, no way to know that the initializer has exactly two components, so we have an invitation for subtle errors. Opinions? |

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