This following shows that functions in Axiom have types and a domain for functions may be associated with an identifier. fricas (1) -> dom:=(INT->INT)
Type: Type
fricas f:dom Type: Void
fricas f x == x-1 Type: Void
However, when the function is compiled, the returned type displayed may not agree with its declared type or even its apparent compiled type and depends on the input! fricas f 3 fricas Compiling function f with type Integer -> Integer
Type: PositiveInteger?
fricas f(-3)
Type: Integer
This has nothing to do with the declaration of fricas f(x:INT):INT==x-1 Type: Void
fricas f(3) fricas Compiling function f with type Integer -> Integer
Type: PositiveInteger?
fricas f(-3)
Type: Integer
Not even: fricas f(x:INT):INT==(x-1)::INT Type: Void
fricas f(3) fricas Compiling function f with type Integer -> Integer
Type: PositiveInteger?
fricas f(-3)
Type: Integer
Or even: fricas g(x:INT):NNI == 2^(sign(x)*x)::NNI Type: Void
fricas g 3 fricas Compiling function g with type Integer -> NonNegativeInteger fricas Compiling function G0 with type Integer -> Boolean
Type: PositiveInteger?
The following deliberate "error" shows the Interpreter always assumes fricas f 3
Type: PositiveInteger?
fricas f -3 Compare the type returned below for fricas g(x:INT): FRAC INT == 1/x Type: Void
fricas g 1 fricas Compiling function g with type Integer -> Fraction(Integer)
Type: Fraction(Integer)
The difference may perhaps be due to the fact that the data structure of Invalid --gdr, Tue, 25 Nov 2008 08:53:43 -0800 reply Status: open => rejected
The report is confused. There is a distinction between function's declared type (which does not change), and the type inferred by the interpreter for the value computed by a function. These are two separate processes. |