This function should return a type that depends on a
parameter:
fricas
tt:INT->Type
Type: Void
fricas
tt(x)== (x=0 => Integer; Float)
Type: Void
fricas
tt(1)
fricas
Compiling function tt with type Integer -> Type
Type: Type
Here is the same function in SPAD:
spad
)abbrev package TT testtype
testtype(): exports == implementation where
exports == with
tt1: (Integer) -> Type
implementation == add
tt1(x) ==
x=0 => Integer
Float
spad
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px002.spad
using old system compiler.
TT abbreviates package testtype
------------------------------------------------------------------------
initializing NRLIB TT for testtype
compiling into NRLIB TT
compiling exported tt1 : Integer -> Type
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |testtype| REDEFINED
;;; *** |testtype| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor testtype
Time: 0 seconds
finalizing NRLIB TT
Processing testtype for Browser database:
--->-->testtype(constructor): Not documented!!!!
--->-->testtype((tt1 ((Type) (Integer)))): Not documented!!!!
--->-->testtype(): Missing Description
; compiling file "/var/aw/var/LatexWiki/TT.NRLIB/TT.lsp" (written 13 MAY 2014 05:14:51 PM):
; /var/aw/var/LatexWiki/TT.NRLIB/TT.fasl written
; compilation finished in 0:00:00.009
------------------------------------------------------------------------
testtype is now explicitly exposed in frame initial
testtype will be automatically loaded when needed from
/var/aw/var/LatexWiki/TT.NRLIB/TT
Calling this function like this::
fricas
tt1(1)
Type: Type
caused Axiom to crash:
(1) -> tt1(1)
>> System error:
Caught fatal error [memory may be damaged]
But this works using Aldor! :-)
aldor
#include "axiom.as";
testtype2(): with {
tt2: (Integer) -> Type;
} == add {
tt2(x:Integer):Type == {
x=0 => Integer;
Float;
}
}
aldor
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7383689924623811223-25px004.as
using AXIOM-XL compiler and options
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
Use the system command )set compiler args to change these
options.
The )library system command was not called after compilation.
fricas
tt2(1)
There are no library operations named tt2
Use HyperDoc Browse or issue
)what op tt2
to learn if there is any operation containing " tt2 " in its
name.
Cannot find a definition or applicable library operation named tt2
with argument type(s)
PositiveInteger
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
tt2(0)
There are no library operations named tt2
Use HyperDoc Browse or issue
)what op tt2
to learn if there is any operation containing " tt2 " in its
name.
Cannot find a definition or applicable library operation named tt2
with argument type(s)
NonNegativeInteger
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
The problem here, I believe, is that Type is a category almost isolated.
The interpreter thinks of Integer and Float as of type Domain, not Type.
If you change the return type from `Type' to `Domain'. It would not
work in
OpenAxiom. Both `Type' and `Object' seems to be isolated in
the type hierarchy.
This issue is fixed in
OpenAxiom-1.2.0.
Comment from me on Friday January 25, 2008 had a typo in it: I meant
If you change the return type from `Type' to `Domain'. It would work in
OpenAxiom.
Now, the original testcase just works fine.
fricas
tt:INT->Domain
Compiled code for tt has been cleared.
Type: Void
fricas
tt(x)== (x=0 => Integer; Float)
1 old definition(s) deleted for function or rule tt
Type: Void
fricas
tt(1)
fricas
Compiling function tt with type Integer -> NIL
There are no library operations named tt
Use HyperDoc Browse or issue
)what op tt
to learn if there is any operation containing " tt " in its name.
Cannot find a definition or applicable library operation named tt
with argument type(s)
Integer
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
Status: open => fixed somewhere
If I define a function that returns a domain (such as above):
fricas
tt:INT->Type
Compiled code for tt has been cleared.
Type: Void
fricas
tt(x)== (x=0 => Integer; Float)
1 old definition(s) deleted for function or rule tt
Type: Void
fricas
tt(0)
fricas
Compiling function tt with type Integer -> Type
Type: Type
then can I use it to define new objects? Like this:
fricas
f:tt(1):=3.2
Type: Float
fricas
g:tt(0):=3
Type: Integer
or this:
fricas
F:=tt(1)
Type: Type
fricas
f:F:=3.2
Type: Float
fricas
G:=tt(0)
Type: Type
fricas
g:G:=3
Type: Integer
Same function in SPAD:
spad
)abbrev package TT testtype
testtype(): exports == implementation where
exports == with
tt1: (Integer) -> Type
implementation == add
tt1(x) ==
x=0 => Integer
Float
spad
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px010.spad
using old system compiler.
TT abbreviates package testtype
------------------------------------------------------------------------
initializing NRLIB TT for testtype
compiling into NRLIB TT
compiling exported tt1 : Integer -> Type
;;; *** |TT;tt1;IT;1| REDEFINED
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |testtype| REDEFINED
;;; *** |testtype| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor testtype
Time: 0 seconds
finalizing NRLIB TT
Processing testtype for Browser database:
--->/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px002.spad-->testtype(constructor): Not documented!!!!
--->/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px002.spad-->testtype((tt1 ((Type) (Integer)))): Not documented!!!!
--->/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px002.spad-->testtype(): Missing Description
; compiling file "/var/aw/var/LatexWiki/TT.NRLIB/TT.lsp" (written 13 MAY 2014 05:14:53 PM):
; /var/aw/var/LatexWiki/TT.NRLIB/TT.fasl written
; compilation finished in 0:00:00.008
------------------------------------------------------------------------
testtype is already explicitly exposed in frame initial
testtype will be automatically loaded when needed from
/var/aw/var/LatexWiki/TT.NRLIB/TT
Calling the function like this now works::
fricas
FF:=tt1(1)
You have used the abbreviation FF of the constructor FiniteField on
the left-hand side of an assignment expression. This is not
allowed.
But can we use it?
fricas
f:FF:=1.2
Although FiniteField is the name of a constructor, a full type must
be specified in the context you have used it. Issue )show
FiniteField for more information.
Same function in SPAD:
spad
)abbrev package TT testtype
testtype(): exports == implementation where
exports == with
tt1: (Integer) -> Type
implementation == add
tt1(x) ==
x=0 => Integer
Float
spad
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px013.spad
using old system compiler.
TT abbreviates package testtype
------------------------------------------------------------------------
initializing NRLIB TT for testtype
compiling into NRLIB TT
compiling exported tt1 : Integer -> Type
;;; *** |TT;tt1;IT;1| REDEFINED
Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |testtype| REDEFINED
;;; *** |testtype| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor testtype
Time: 0.01 seconds
finalizing NRLIB TT
Processing testtype for Browser database:
--->/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px010.spad-->testtype(constructor): Not documented!!!!
--->/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px010.spad-->testtype((tt1 ((Type) (Integer)))): Not documented!!!!
--->/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8965653050310018446-25px010.spad-->testtype(): Missing Description
; compiling file "/var/aw/var/LatexWiki/TT.NRLIB/TT.lsp" (written 13 MAY 2014 05:14:55 PM):
; /var/aw/var/LatexWiki/TT.NRLIB/TT.fasl written
; compilation finished in 0:00:00.036
------------------------------------------------------------------------
testtype is already explicitly exposed in frame initial
testtype will be automatically loaded when needed from
/var/aw/var/LatexWiki/TT.NRLIB/TT
Calling the function like this now works::
fricas
TofF:=tt1(1)
Type: Type
But can we use it?
fricas
f:TofF:=1.2
Type: Float