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

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

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

\label{eq1}\hbox{\axiomType{Float}\ }(1)
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)

\label{eq2}\hbox{\axiomType{Float}\ }(2)
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

functions that return domains --Bill Page, Mon, 25 Feb 2008 07:20:30 -0800 reply
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

\label{eq3}\hbox{\axiomType{Integer}\ }(3)
Type: Type

then can I use it to define new objects? Like this:

fricas
f:tt(1):=3.2

\label{eq4}3.2(4)
Type: Float
fricas
g:tt(0):=3

\label{eq5}3(5)
Type: Integer

or this:

fricas
F:=tt(1)

\label{eq6}\hbox{\axiomType{Float}\ }(6)
Type: Type
fricas
f:F:=3.2

\label{eq7}3.2(7)
Type: Float
fricas
G:=tt(0)

\label{eq8}\hbox{\axiomType{Integer}\ }(8)
Type: Type
fricas
g:G:=3

\label{eq9}3(9)
Type: Integer

Try it again with SPAD --Bill Page, Wed, 27 Feb 2008 21:21:55 -0800 reply
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.

Well, maybe if we don't confuse it too much ... --Bill Page, Wed, 27 Feb 2008 21:24:23 -0800 reply
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)

\label{eq10}\hbox{\axiomType{Float}\ }(10)
Type: Type

But can we use it?

fricas
f:TofF:=1.2

\label{eq11}1.2(11)
Type: Float

Status: fixed somewhere => closed




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: