This function should return a type that depends on a parameter: fricas (1) -> 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. 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 Aldor compiler and options -O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra Use the system command )set compiler args to change these options. "/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7383689924623811223-25px004.as", fricas tt2(1) ... --gdr, Fri, 25 Jan 2008 13:27:44 -0800 reply 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->DomainStatus: open => fixed somewhere If I define a function that returns a domain (such as above): fricas tt:INT->Type Type: Void
fricas tt(x)== (x=0 => Integer; Float) 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 Calling the function like this now works:: fricas FF:=tt1(1) But can we use it? fricas f:FF:=1.2Same 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 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
Status: fixed somewhere => closed
|