|
|
last edited 16 years ago by gdr |
1 2 3 4 5 6 7 8 9 10 11 | ||
Editor: Bill Page
Time: 2008/05/29 14:36:02 GMT-7 |
||
Note: declarations require domains |
added:
From BillPage Thu May 29 14:36:02 -0700 2008
From: Bill Page
Date: Thu, 29 May 2008 14:36:02 -0700
Subject: declarations require domains
Message-ID: <20080529143602-0700@axiom-wiki.newsynthesis.org>
Something is still inconsistent here::
(1) -> ST(x:Integer):Category == (x=0 => SetCategory;Type)
Function declaration ST : Integer -> Category has been added to
workspace.
Type: Void
(2) -> A:=ST(0)
Compiling function ST with type Integer -> Category
;;; *** |*1;ST;1;frame1392| REDEFINED
; (DEFUN |*1;ST;1;frame1392| ...) is being compiled.
;; The variable |*1;ST;1;frame1392;MV| is undefined.
;; The compiler will assume this variable is a global.
(2) SetCategory
Type: Category
(3) -> B:=ST(1)
(3) Type
Type: Category
(4) -> C:Category
Category is a category, not a domain, and declarations require
domains.
(4) -> C:Category:=Ring
Category is a category, not a domain, and declarations require
domains.
(4) -> C:=Ring
(4) Ring
Type: Category
(5) -> )display type X
Type of value of X: Category
-------
If the type of a category-valued variable can be implicitly
made to be 'Category', it should also be possible to declare
this to be so.
In OpenAxiom? one should be able to write a function that returns a 'Category':
axiomST(x:Integer):Category == (x=0 => SetCategory;Type) Function declaration ST : Integer -> Category has been added to workspace.
axiomST(0) Internal Error Interpreter code generation failed for expression (IF (= |#1| 0) |SetCategory| |Type|)
but we get the error message:
Internal Error Interpreter code generation failed for expression (IF (= |#1| 0) |SetCategory| |Type|)
This is ok for functions that return 'Domain':
axiomFI(x:Integer):Domain == (x=0 => Float;Integer) Function declaration FI : Integer -> Domain has been added to workspace.
axiomFI(0)
Compiling function FI with type Integer -> Domain ; (DEFUN |*1;FI;1;initial| ...) is being compiled. ;; The variable |*1;FI;1;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
![]() | (1) |
axiomFI(1)
![]() | (2) |
However, in the interpreter we should probably try to accomodate for as much as we can because we can also do a small step semantics, e.g. interpret literally the codes.
Going back to your problem, an issue here is with what the type of Type should be. Currently, OpenAxiom? says that Type has type Type, instead of Category:
axiomType
![]() | (3) |
axiomtypeOf Type
![]() | (4) |
Another option might be to say that Type has type Category. That would make your function OK. Note that the following works fine
axiomST2(x: Integer): Category == (x=0 => SetCategory; Ring) Function declaration ST2 : Integer -> Category has been added to workspace.
axiomST2 0
Compiling function ST2 with type Integer -> Category ; (DEFUN |*1;ST2;1;initial| ...) is being compiled. ;; The variable |*1;ST2;1;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
![]() | (5) |
axiomST2 1
![]() | (6) |
(1) -> ST(x:Integer):Category == (x=0 => SetCategory;Type) Function declaration ST : Integer -> Category has been added to workspace. Type: Void (2) -> A:=ST(0) Compiling function ST with type Integer -> Category ;;; *** |*1;ST;1;frame1392| REDEFINED ; (DEFUN |*1;ST;1;frame1392| ...) is being compiled. ;; The variable |*1;ST;1;frame1392;MV| is undefined. ;; The compiler will assume this variable is a global. (2) SetCategory Type: Category (3) -> B:=ST(1) (3) Type Type: Category (4) -> C:Category Category is a category, not a domain, and declarations require domains. (4) -> C:Category:=Ring Category is a category, not a domain, and declarations require domains. (4) -> C:=Ring (4) Ring Type: Category (5) -> )display type X Type of value of X: Category
-------
If the type of a category-valued variable can be implicitly
made to be Category
, it should also be possible to declare
this to be so.