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

Edit detail for SandBoxMaybe revision 45 of 46

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Editor: Bill Page
Time: 2013/03/15 20:45:05 GMT+0
Note: newer version of OpenAxiom

removed:
-

spad
)abbrev domain MAYBE Maybe
Maybe(T: Type) == Union(T,"failed")
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3867167196268790065-25px001.spad
      using Spad compiler.
   MAYBE abbreviates domain Maybe 
------------------------------------------------------------------------
   initializing NRLIB MAYBE for Maybe 
   compiling into NRLIB MAYBE 
   Adding $ modemaps
   Adding T$ modemaps
(time taken in buildFunctor:  0)
;;; *** |Maybe| REDEFINED
;;; *** |Maybe| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Maybe Time: 0 seconds
>> System error: The value |%bind| is not of type REAL.

need result type --Bill Page, Mon, 26 May 2008 20:25:03 -0700 reply
spad
)abbrev domain MAYBE Maybe
Maybe(T: Type):Type == Union(T,"failed")
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6798525157762352212-25px002.spad
      using Spad compiler.
   MAYBE abbreviates domain Maybe 
------------------------------------------------------------------------
   initializing NRLIB MAYBE for Maybe 
   compiling into NRLIB MAYBE 
   Adding $ modemaps
   Adding T$ modemaps
(time taken in buildFunctor:  0)
;;; *** |Maybe| REDEFINED
;;; *** |Maybe| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Maybe Time: 0 seconds
--------------non extending category---------------------- Maybe #1 of category Type has no UnionCategory(#1,"failed") ---------------------------------------------------------- finalizing NRLIB MAYBE Processing Maybe for Browser database: --->/usr/local/lib/open-axiom/x86_64-unknown-linux-gnu/1.4.0-2011-02-20/src/algebra/MAYBE.spad-->Maybe: Missing Description
; compiling file "/var/aw/var/LatexWiki/MAYBE.NRLIB/code.lsp" (written 25 MAR 2013 03:45:29 PM): ; compiling (/VERSIONCHECK 2) ; compiling (DEFUN |Maybe| ...) ; compiling (DEFUN |Maybe;| ...) ; compiling (MAKEPROP (QUOTE |Maybe|) ...)
; /var/aw/var/LatexWiki/MAYBE.NRLIB/code.fasl written ; compilation finished in 0:00:00.011 ------------------------------------------------------------------------ Maybe is now explicitly exposed in frame initial Maybe will be automatically loaded when needed from /var/aw/var/LatexWiki/MAYBE.NRLIB/code.fasl

axiom
)show Maybe
Maybe T$: Type is a domain constructor Abbreviation for Maybe is MAYBE This constructor is exposed in this frame. Issue )edit /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6798525157762352212-25px002.spad to see algebra source code for MAYBE
------------------------------- Operations -------------------------------- No exported operations

need result type --gdr, Mon, 26 May 2008 22:03:52 -0700 reply
No, there should not be a need for specifying result type. In fact, if you specify "Type" as result type, you explicitly ask for not having any exported operation. That wasn't the intent. The intent was to get whatever the right hand side exported as exports. Such as in
spad
)abbrev domain MYFIELD MyField
MyField() == Fraction Integer
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/2205496008028295448-25px004.spad
      using Spad compiler.
   MYFIELD abbreviates domain MyField 
------------------------------------------------------------------------
   initializing NRLIB MYFIELD for MyField 
   compiling into NRLIB MYFIELD 
   Adding $ modemaps
   Adding $ modemaps
 Note: Domain $ already in scope
   augmenting $: CharacteristicNonZero
   Adding Integer modemaps
   augmenting Integer: PolynomialFactorizationExplicit
   Adding $ modemaps
 Note: Domain $ already in scope
   augmenting $: CharacteristicNonZero
   Adding Integer modemaps
   augmenting Integer: PolynomialFactorizationExplicit
   Adding Integer modemaps
   augmenting Integer: ConvertibleTo Pattern Float
   Adding Integer modemaps
   augmenting Integer: Eltable(Integer,Integer)
   Adding Integer modemaps
   augmenting Integer: Evalable Integer
   Adding Integer modemaps
   augmenting Integer: InnerEvalable(Symbol,Integer)
   Adding Integer modemaps
   augmenting Integer: PartialDifferentialSpace Symbol
   Adding Integer modemaps
   augmenting Integer: PatternMatchable Float
   Adding Integer modemaps
   augmenting Integer: PolynomialFactorizationExplicit
   Adding Integer modemaps
   augmenting Integer: RetractableTo Symbol
(time taken in buildFunctor:  340)
;;; *** |MyField| REDEFINED
;;; *** |MyField| REDEFINED Time: 0.56 SEC.
Cumulative Statistics for Constructor MyField Time: 0.56 seconds
finalizing NRLIB MYFIELD Processing MyField for Browser database: --->-->MyField: Missing Description ; compiling file "/var/aw/var/LatexWiki/MYFIELD.NRLIB/code.lsp" (written 25 MAR 2013 03:45:30 PM): ; compiling (/VERSIONCHECK 2) ; compiling (DEFUN |MyField| ...) ; compiling (DEFUN |MyField;| ...) ; compiling (MAKEPROP (QUOTE |MyField|) ...) ; compiling (MAKEPROP (QUOTE |MyField|) ...)
; /var/aw/var/LatexWiki/MYFIELD.NRLIB/code.fasl written ; compilation finished in 0:00:00.013 ------------------------------------------------------------------------ MyField is now explicitly exposed in frame initial MyField will be automatically loaded when needed from /var/aw/var/LatexWiki/MYFIELD.NRLIB/code.fasl

axiom
)sh MyField
MyField is a domain constructor Abbreviation for MyField is MYFIELD This constructor is exposed in this frame. Issue )edit /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/2205496008028295448-25px004.spad to see algebra source code for MYFIELD
------------------------------- Operations -------------------------------- ?*? : (%,Integer) -> % ?*? : (Integer,%) -> % ?*? : (Fraction Integer,%) -> % ?*? : (%,Fraction Integer) -> % ?*? : (%,%) -> % ?*? : (Integer,%) -> % ?*? : (PositiveInteger,%) -> % ?**? : (%,Integer) -> % ?**? : (%,PositiveInteger) -> % ?+? : (%,%) -> % ?-? : (%,%) -> % -? : % -> % ?/? : (Integer,Integer) -> % ?/? : (%,%) -> % ?=? : (%,%) -> Boolean 1 : () -> % 0 : () -> % associates? : (%,%) -> Boolean before? : (%,%) -> Boolean coerce : Integer -> % coerce : Fraction Integer -> % coerce : % -> % coerce : Integer -> % coerce : % -> OutputForm denom : % -> Integer denominator : % -> % factor : % -> Factored % gcd : List % -> % gcd : (%,%) -> % hash : % -> SingleInteger inv : % -> % latex : % -> String lcm : List % -> % lcm : (%,%) -> % numer : % -> Integer numerator : % -> % one? : % -> Boolean prime? : % -> Boolean ?quo? : (%,%) -> % recip : % -> Union(%,"failed") ?rem? : (%,%) -> % retract : % -> Integer sample : () -> % sizeLess? : (%,%) -> Boolean squareFree : % -> Factored % squareFreePart : % -> % unit? : % -> Boolean unitCanonical : % -> % zero? : % -> Boolean ?~=? : (%,%) -> Boolean ?*? : (NonNegativeInteger,%) -> % ?**? : (%,NonNegativeInteger) -> % ?<? : (%,%) -> Boolean if Integer has ORDSET ?<=? : (%,%) -> Boolean if Integer has ORDSET ?>? : (%,%) -> Boolean if Integer has ORDSET ?>=? : (%,%) -> Boolean if Integer has ORDSET D : (%,NonNegativeInteger) -> % if Integer has DIFFSPC D : % -> % if Integer has DIFFSPC D : (%,List Symbol,List NonNegativeInteger) -> % if Integer has PDSPC SYMBOL D : (%,Symbol,NonNegativeInteger) -> % if Integer has PDSPC SYMBOL D : (%,List Symbol) -> % if Integer has PDSPC SYMBOL D : (%,Symbol) -> % if Integer has PDSPC SYMBOL D : (%,(Integer -> Integer),NonNegativeInteger) -> % D : (%,(Integer -> Integer)) -> % OMwrite : (OpenMathDevice,%,Boolean) -> Void if Integer has INS and Integer has OM OMwrite : (OpenMathDevice,%) -> Void if Integer has INS and Integer has OM OMwrite : (%,Boolean) -> String if Integer has INS and Integer has OM OMwrite : % -> String if Integer has INS and Integer has OM abs : % -> % if Integer has OINTDOM ceiling : % -> Integer if Integer has INS characteristic : () -> NonNegativeInteger charthRoot : % -> Union(%,"failed") if $ has CHARNZ and Integer has PFECAT or Integer has CHARNZ coerce : Symbol -> % if Integer has RETRACT SYMBOL conditionP : Matrix % -> Union(Vector %,"failed") if $ has CHARNZ and Integer has PFECAT convert : % -> DoubleFloat if Integer has REAL convert : % -> Float if Integer has REAL convert : % -> InputForm if Integer has KONVERT INFORM convert : % -> Pattern Float if Integer has KONVERT PATTERN FLOAT convert : % -> Pattern Integer if Integer has KONVERT PATTERN INT differentiate : (%,NonNegativeInteger) -> % if Integer has DIFFSPC differentiate : % -> % if Integer has DIFFSPC differentiate : (%,List Symbol,List NonNegativeInteger) -> % if Integer has PDSPC SYMBOL differentiate : (%,Symbol,NonNegativeInteger) -> % if Integer has PDSPC SYMBOL differentiate : (%,List Symbol) -> % if Integer has PDSPC SYMBOL differentiate : (%,Symbol) -> % if Integer has PDSPC SYMBOL differentiate : (%,(Integer -> Integer),NonNegativeInteger) -> % differentiate : (%,(Integer -> Integer)) -> % divide : (%,%) -> Record(quotient: %,remainder: %) ?.? : (%,Integer) -> % if Integer has ELTAB(INT,INT) euclideanSize : % -> NonNegativeInteger eval : (%,Symbol,Integer) -> % if Integer has IEVALAB(SYMBOL,INT) eval : (%,List Symbol,List Integer) -> % if Integer has IEVALAB(SYMBOL,INT) eval : (%,List Equation Integer) -> % if Integer has EVALAB INT eval : (%,Equation Integer) -> % if Integer has EVALAB INT eval : (%,Integer,Integer) -> % if Integer has EVALAB INT eval : (%,List Integer,List Integer) -> % if Integer has EVALAB INT expressIdealMember : (List %,%) -> Union(List %,"failed") exquo : (%,%) -> Union(%,"failed") extendedEuclidean : (%,%,%) -> Union(Record(coef1: %,coef2: %),"failed") extendedEuclidean : (%,%) -> Record(coef1: %,coef2: %,generator: %) factorPolynomial : SparseUnivariatePolynomial % -> Factored SparseUnivariatePolynomial % if Integer has PFECAT factorSquareFreePolynomial : SparseUnivariatePolynomial % -> Factored SparseUnivariatePolynomial % if Integer has PFECAT floor : % -> Integer if Integer has INS fractionPart : % -> % if Integer has EUCDOM gcdPolynomial : (SparseUnivariatePolynomial %,SparseUnivariatePolynomial %) -> SparseUnivariatePolynomial % init : () -> % if Integer has STEP leftReducedSystem : Vector % -> Matrix Integer leftReducedSystem : (Vector %,%) -> Record(mat: Matrix Integer,vec: Vector Integer) leftReducedSystem : (Vector %,%) -> Record(mat: Matrix Integer,vec: Vector Integer) if Integer has LINEXP INT leftReducedSystem : Vector % -> Matrix Integer if Integer has LINEXP INT map : ((Integer -> Integer),%) -> % max : (%,%) -> % if Integer has ORDSET min : (%,%) -> % if Integer has ORDSET multiEuclidean : (List %,%) -> Union(List %,"failed") negative? : % -> Boolean if Integer has OINTDOM nextItem : % -> Union(%,"failed") if Integer has STEP patternMatch : (%,Pattern Float,PatternMatchResult(Float,%)) -> PatternMatchResult(Float,%) if Integer has PATMAB FLOAT patternMatch : (%,Pattern Integer,PatternMatchResult(Integer,%)) -> PatternMatchResult(Integer,%) if Integer has PATMAB INT positive? : % -> Boolean if Integer has OINTDOM principalIdeal : List % -> Record(coef: List %,generator: %) random : () -> % if Integer has INS reducedSystem : Matrix % -> Matrix Integer reducedSystem : (Matrix %,Vector %) -> Record(mat: Matrix Integer,vec: Vector Integer) reducedSystem : (Matrix %,Vector %) -> Record(mat: Matrix Integer,vec: Vector Integer) if Integer has LINEXP INT reducedSystem : Matrix % -> Matrix Integer if Integer has LINEXP INT retract : % -> Integer if Integer has RETRACT INT retract : % -> Fraction Integer if Integer has RETRACT INT retract : % -> Symbol if Integer has RETRACT SYMBOL retractIfCan : % -> Union(Integer,"failed") if Integer has RETRACT INT retractIfCan : % -> Union(Fraction Integer,"failed") if Integer has RETRACT INT retractIfCan : % -> Union(Symbol,"failed") if Integer has RETRACT SYMBOL retractIfCan : % -> Union(Integer,"failed") sign : % -> Integer if Integer has OINTDOM solveLinearPolynomialEquation : (List SparseUnivariatePolynomial %,SparseUnivariatePolynomial %) -> Union(List SparseUnivariatePolynomial %,"failed") if Integer has PFECAT squareFreePolynomial : SparseUnivariatePolynomial % -> Factored SparseUnivariatePolynomial % if Integer has PFECAT subtractIfCan : (%,%) -> Union(%,"failed") unitNormal : % -> Record(unit: %,canonical: %,associate: %) wholePart : % -> Integer if Integer has EUCDOM

Macro versus domain
axiom
macro Maybe(T) == Union(T,"failed")
Type: Void
axiom
)sh Maybe(Integer)
Union(Integer,"failed") is a domain constructor. ------------------------------- Operations --------------------------------
?=? : (%,%) -> Boolean autoCoerce : % -> "failed" autoCoerce : % -> Integer autoCoerce : "failed" -> % autoCoerce : Integer -> % ?case? : (%,"failed") -> Boolean ?case? : (%,Integer) -> Boolean coerce : % -> "failed" coerce : % -> Integer coerce : % -> OutputForm hash : % -> SingleInteger ?~=? : (%,%) -> Boolean

axiom
x:Maybe(Integer)
Type: Void
axiom
x:=-3

\label{eq1}- 3(1)
Type: Union(Integer,...)

explicit exports --Bill Page, Tue, 27 May 2008 07:46:20 -0700 reply
spad
)abbrev domain MAYBE2 Maybe2
Maybe2(T: Type):with
    _= : (%,%) -> Boolean
    autoCoerce : % -> failed
    autoCoerce : % -> T
    autoCoerce : failed -> %
    autoCoerce : T -> %
    _case: (%,failed) -> Boolean
    _case: (%,T) -> Boolean
    coerce : % -> failed
    coerce : % -> T
    coerce : % -> OutputForm
    coerce : T -> %
  == Union(T,"failed") add
    coerce(x:T):% == autoCoerce(x)
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7945389118523770429-25px008.spad
      using Spad compiler.
   MAYBE2 abbreviates domain Maybe2 
------------------------------------------------------------------------
   initializing NRLIB MAYBE2 for Maybe2 
   compiling into NRLIB MAYBE2 
   Adding $ modemaps
   Adding T$ modemaps
   compiling exported coerce : T -> %
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |Maybe2| REDEFINED
;;; *** |Maybe2| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Maybe2 Time: 0 seconds
--------------non extending category---------------------- Maybe2 #1 of category CATEGORY(domain,=: (%,%) -> Boolean, autoCoerce: % -> failed,autoCoerce: % -> #1,autoCoerce: failed -> %,autoCoerce: #1 -> %,case: (%,failed) -> Boolean,case: ( %,#1) -> Boolean,coerce: % -> failed,coerce: % -> #1,coerce: % -> OutputForm,coerce: #1 -> %) has no UnionCategory(#1,"failed") ---------------------------------------------------------- finalizing NRLIB MAYBE2 Processing Maybe2 for Browser database: --->-->Maybe2((= ((Boolean) % %))): Not documented!!!! --->-->Maybe2((autoCoerce (failed %))): Not documented!!!! --->-->Maybe2((autoCoerce (T$ %))): Not documented!!!! --->-->Maybe2((autoCoerce (% failed))): Not documented!!!! --->-->Maybe2((autoCoerce (% T$))): Not documented!!!! --->-->Maybe2((case ((Boolean) % failed))): Not documented!!!! --->-->Maybe2((case ((Boolean) % T$))): Not documented!!!! --->-->Maybe2((coerce (failed %))): Not documented!!!! --->-->Maybe2((coerce (T$ %))): Not documented!!!! --->-->Maybe2((coerce ((OutputForm) %))): Not documented!!!! --->-->Maybe2((coerce (% T$))): Not documented!!!! --->-->Maybe2(constructor): Not documented!!!! --->-->Maybe2: Missing Description ; compiling file "/var/aw/var/LatexWiki/MAYBE2.NRLIB/code.lsp" (written 25 MAR 2013 03:45:30 PM): ; compiling (/VERSIONCHECK 2) ; compiling (DEFUN |MAYBE2;coerce;T$$;1| ...) ; compiling (DEFUN |Maybe2| ...) ; compiling (DEFUN |Maybe2;| ...) ; compiling (MAKEPROP (QUOTE |Maybe2|) ...)
; /var/aw/var/LatexWiki/MAYBE2.NRLIB/code.fasl written ; compilation finished in 0:00:00.010 ------------------------------------------------------------------------ Maybe2 is now explicitly exposed in frame initial Maybe2 will be automatically loaded when needed from /var/aw/var/LatexWiki/MAYBE2.NRLIB/code.fasl

axiom
)show Maybe2
Maybe2 T$: Type is a domain constructor Abbreviation for Maybe2 is MAYBE2 This constructor is exposed in this frame. Issue )edit /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7945389118523770429-25px008.spad to see algebra source code for MAYBE2
------------------------------- Operations -------------------------------- ?=? : (%,%) -> Boolean autoCoerce : % -> failed autoCoerce : % -> T autoCoerce : failed -> % autoCoerce : T -> % ?case? : (%,failed) -> Boolean ?case? : (%,T) -> Boolean coerce : % -> failed coerce : % -> T coerce : % -> OutputForm coerce : T -> %

axiom
y:Maybe2(Integer)
Type: Void
axiom
y:=-3
Function: autoCoerce : Integer -> % is missing from domain: Maybe2 Integer Internal Error The function autoCoerce with signature $(Integer) is missing from domain Maybe2(Integer)
Continuing to read the file...
y:=autoCoerce(-3::Integer)
Internal Error The function autoCoerce with signature Integer -> % is missing from domain Maybe2(Integer)
Continuing to read the file...

But, the use of macro is a workaround a fundamental problem in the compiler -- which I'm desperately trying to convey.

explicit exports --gdr, Tue, 27 May 2008 08:03:19 -0700 reply
This and the original bug comes from the same source in the compiler.

Re: problem in the compiler --Bill Page, Tue, 27 May 2008 08:06:29 -0700 reply
I agree. I am just trying to understand it.

Why does:

  Maybe(T: Type) == Union(T,"failed")

and:

  Maybe(T: Type):Type == Union(T,"failed")

have such different semantics? Is this a good thing? Maybe there is a need for something that stands for the type of the rhs:

  Maybe(T: Type):rhs == Union(T,"failed")

Re: problem in the compiler --gdr, Tue, 27 May 2008 09:20:19 -0700 reply
Remember that Type is a category that exports no operation. so when you say Maybe(T: Type): Type, you are exlicitly saying that Maybe(T: Type) is a domain constructor that exports no operation. Indeed, if you try )show with OpenAxiom?, you will see that it say, Maybe has no exported operations. Which is right.

However, when one says Maybe(T: Type) == Union(T, "failed"), one is saying that Maybe(T) is exactly like Union(T,"failed"), except for the name. Consequently, Maybe has the exports inferred from the right hand side. This works for all domains, except the `builtin' domains. If you try Record or Enumeration, you should hit a bug in the compiler at some point.

exports inferred from RHS --Bill Page, Tue, 27 May 2008 12:58:47 -0700 reply
spad
)abbrev domain MYPAIR MyPair
MyPair(T:Type) == Record(X:T,Y:T)
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1259072050906152969-25px011.spad
      using Spad compiler.
   MYPAIR abbreviates domain MyPair 
------------------------------------------------------------------------
   initializing NRLIB MYPAIR for MyPair 
   compiling into NRLIB MYPAIR 
   Adding $ modemaps
   Adding T$ modemaps
(time taken in buildFunctor:  0)
;;; *** |MyPair| REDEFINED
;;; *** |MyPair| REDEFINED Time: 0.01 SEC.
Cumulative Statistics for Constructor MyPair Time: 0.01 seconds
>> System error: The value SETRECORDELT is not of type REAL.

axiom
)show MyPair(Integer)
MyPair is an unknown constructor and so is unavailable. Did you mean to use -> but type something different instead?

spad
)abbrev domain MYPAIR2 MyPair2
MyPair2(T:Type): with
    _= : (%,%) -> Boolean
    coerce : % -> OutputForm
    copy : % -> %
    _. : (%,X) -> Integer
    _. : (%,Y) -> Integer
    setelt : (%,X,Integer) -> Integer
    setelt : (%,Y,Integer) -> Integer
    _~_= : (%,%) -> Boolean
    construct : (Integer,Integer) -> %
  == Record(X:T,Y:T)
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5737796087530002187-25px013.spad
      using Spad compiler.
   MYPAIR2 abbreviates domain MyPair2 
------------------------------------------------------------------------
   initializing NRLIB MYPAIR2 for MyPair2 
   compiling into NRLIB MYPAIR2 
   Adding $ modemaps
   Adding T$ modemaps
(time taken in buildFunctor:  0)
;;; *** |MyPair2| REDEFINED
;;; *** |MyPair2| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor MyPair2 Time: 0 seconds
--------------non extending category---------------------- MyPair2 #1 of category CATEGORY(domain,=: (%,%) -> Boolean,coerce : % -> OutputForm,copy: % -> %,.: (%,X) -> Integer,.: (%,Y) -> Integer,setelt: (%,X,Integer) -> Integer,setelt: (%,Y, Integer) -> Integer,~=: (%,%) -> Boolean,construct: (Integer, Integer) -> %) has no RecordCategory(X: #1,Y: #1) ---------------------------------------------------------- finalizing NRLIB MYPAIR2 Processing MyPair2 for Browser database: --->-->MyPair2((= ((Boolean) % %))): Not documented!!!! --->-->MyPair2((coerce ((OutputForm) %))): Not documented!!!! --->-->MyPair2((copy (% %))): Not documented!!!! --->-->MyPair2((. ((Integer) % X))): Not documented!!!! --->-->MyPair2((. ((Integer) % Y))): Not documented!!!! --->-->MyPair2((setelt ((Integer) % X (Integer)))): Not documented!!!! --->-->MyPair2((setelt ((Integer) % Y (Integer)))): Not documented!!!! --->-->MyPair2((~= ((Boolean) % %))): Not documented!!!! --->-->MyPair2((construct (% (Integer) (Integer)))): Not documented!!!! --->-->MyPair2(constructor): Not documented!!!! --->-->MyPair2: Missing Description ; compiling file "/var/aw/var/LatexWiki/MYPAIR2.NRLIB/code.lsp" (written 25 MAR 2013 03:45:30 PM): ; compiling (/VERSIONCHECK 2) ; compiling (DEFUN |MyPair2| ...) ; compiling (DEFUN |MyPair2;| ...) ; compiling (MAKEPROP (QUOTE |MyPair2|) ...)
; /var/aw/var/LatexWiki/MYPAIR2.NRLIB/code.fasl written ; compilation finished in 0:00:00.008 ------------------------------------------------------------------------ MyPair2 is now explicitly exposed in frame initial MyPair2 will be automatically loaded when needed from /var/aw/var/LatexWiki/MYPAIR2.NRLIB/code.fasl

axiom
)show MyPair2(Integer)
MyPair2 Integer is a domain constructor. Abbreviation for MyPair2 is MYPAIR2 This constructor is exposed in this frame. Issue )edit /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5737796087530002187-25px013.spad to see algebra source code for MYPAIR2
------------------------------- Operations --------------------------------
?.? : (%,X) -> Integer ?.? : (%,Y) -> Integer ?=? : (%,%) -> Boolean coerce : % -> OutputForm copy : % -> % setelt : (%,X,Integer) -> Integer setelt : (%,Y,Integer) -> Integer ?~=? : (%,%) -> Boolean construct : (Integer,Integer) -> %

axiom
x2:MyPair2(INT):=[-1,-2]
Internal Error The function construct with signature (Integer,Integer) -> % is missing from domain MyPair2(Integer)
Continuing to read the file...

Maybe(T:Type)== --Bill Page, Tue, 27 May 2008 13:37:18 -0700 reply
gdr wrote:

  • one is saying that Maybe(T) is exactly like Union(T,"failed")

What is the advantage of this notation over the use of a macro?

Besides domain composition, constant substitution and passing of parameters, like:

  Maybe(T: Type) == Union(Fraction T,"failed")

what other useful expressions are allowed on the rhs?

Persumably add would not make sense because we cannot specify new exports - at least not without explicitly specifying all exports.

This is a common problem for possible re-use of code (subject of another thread). For example:

   NonNegativeInteger():rhs
     without
       _-:(%,%) -> %
     with
       subtractIfCan:(%,%)->Union(%,"failed")
   == Integer add
     subtractIfCan(x,y) ==
       x > y => x-y
       "failed"

What should I put instead of rhs? Should I be able to explicitly "forget" (or replace) some exports?

spad
)abbrev domain MYNNI MyNonNegativeInteger
MyNonNegativeInteger():IntegerNumberSystem with
    subtractIfCan:(%,%)->Union(%,"failed")
  == Integer add
    subtractIfCan(x:%,y:%):Union(%,"failed") ==
      x > y => x-y
      "failed"
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5893753003779373514-25px016.spad
      using Spad compiler.
   MYNNI abbreviates domain MyNonNegativeInteger 
------------------------------------------------------------------------
   initializing NRLIB MYNNI for MyNonNegativeInteger 
   compiling into NRLIB MYNNI 
   Adding $ modemaps
   compiling exported subtractIfCan : (%,%) -> Union(%,failed)
   Adding Boolean modemaps
Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |MyNonNegativeInteger| REDEFINED
;;; *** |MyNonNegativeInteger| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor MyNonNegativeInteger Time: 0.01 seconds
(|RealConstant|) extends (|ConvertibleTo| (|DoubleFloat|)) but not (|ConvertibleTo| (|String|)) --------------non extending category---------------------- MyNonNegativeInteger of category IntegerNumberSystem with subtractIfCan : (%,%) -> Union(%,"failed") has no ConvertibleTo String ---------------------------------------------------------- finalizing NRLIB MYNNI Processing MyNonNegativeInteger for Browser database: --->-->MyNonNegativeInteger((subtractIfCan ((Union % failed) % %))): Not documented!!!! --->-->MyNonNegativeInteger(constructor): Not documented!!!! --->-->MyNonNegativeInteger: Missing Description ; compiling file "/var/aw/var/LatexWiki/MYNNI.NRLIB/code.lsp" (written 25 MAR 2013 03:45:30 PM): ; compiling (/VERSIONCHECK 2) ; compiling (DEFUN |MYNNI;subtractIfCan;2$U;1| ...) ; compiling (DEFUN |MyNonNegativeInteger| ...) ; compiling (DEFUN |MyNonNegativeInteger;| ...) ; compiling (MAKEPROP (QUOTE |MyNonNegativeInteger|) ...) ; compiling (MAKEPROP (QUOTE |MyNonNegativeInteger|) ...)
; /var/aw/var/LatexWiki/MYNNI.NRLIB/code.fasl written ; compilation finished in 0:00:00.012 ------------------------------------------------------------------------ MyNonNegativeInteger is now explicitly exposed in frame initial MyNonNegativeInteger will be automatically loaded when needed from /var/aw/var/LatexWiki/MYNNI.NRLIB/code.fasl

A macro name is not a constructor name, so that makes a fundamental difference.

Do we have a `without' construct?

With an OpenAxiom? built on May 16, 2008 I have a different behaviour: The assignment is rejected because there is no conversion from [-1,2] to MyPair2(INT). Which is right. The output of the compiler indicates to me that the website is running a very old OpenAxiom?.

The version of OpenAxiom? being used for this page was build from svn on May 27, 2008:
axiom
)version
Value = "Monday March 7, 2011 at 19:18:42 "

Re: without construct --page, Tue, 27 May 2008 15:46:58 -0700 reply
No, it's only in my imagination.

Previously Bill Page wrote:
  Macro versus domain

    macro Maybe(T) == Union(T,"failed")

gdr wrote:

  But, the use of macro is a workaround a fundamental problem
  in the compiler ...

Bill Page wrote:

  Agreed, but what is the advantage of this notation:

    Maybe(T:Type) == Union(T,"failed")

  over the use of a macro?

gdr wrote:

  A macro name is not a constructor name, so that makes
  a fundamental difference.

Of course there is a difference to the compiler but is there a "fundamental difference" to the programmer? Does the language benefit from being able to compile domains with an identical list exports as some other domain?

I suppose here's one possible advantage:

  • To provide standard simplified interfaces to more complex domains defined in the library.
  • Macros are not stored as part of the Axiom library.

Well, as you said, macros are not stored in the databases. In OpenAxiom?, one can use constructor names as arguments to functions. That does not work with macro names -- they don't really define a new category or domain or package.

Something you can only do in OpenAxiom?! --page, Tue, 27 May 2008 17:42:52 -0700 reply
Because you can pass domains as arguments to functions:
axiom
Maybe3(T: Domain):Domain == Union(T,"failed")
Function declaration Maybe3 : Domain -> Domain has been added to workspace.
Type: Void
axiom
x:Maybe3(Integer):=-2
axiom
Compiling function Maybe3 with type Domain -> Domain

\label{eq2}- 2(2)
Type: Union(Integer,...)
axiom
x:="failed"

\label{eq3}\mbox{\tt "failed"}(3)
Type: Union("failed",...)

Internal Error --page, Tue, 27 May 2008 20:49:00 -0700 reply
gdr wrote:
  With an OpenAxiom built on May 16, 2008 I have a different behaviour:
  The assignment is rejected because there is no conversion from
  [-1,2] to MyPair2(INT).

After upgrading this page to OpenAxiom? built with current (May 27, 2008 Rev: 614) source:

axiom
)version
Value = "Monday March 7, 2011 at 19:18:42 "

This example still fails:

axiom
xy:MyPair2(INT):=[-1,2]
Internal Error The function construct with signature (Integer,Integer) -> % is missing from domain MyPair2(Integer)
Continuing to read the file...

this is weird: I cannot reproduce the failure.

I can reproduce the failure --gdr, Wed, 28 May 2008 00:05:03 -0700 reply
Now, I can
I failed to copy and paste properly. And on reflection, the fact the interpreter rejected the code should have alerted me to close closer. And yes, the failure is related to the same bug.