Start Code
ComplexClass: AC.StructureClass ← NEW[AC.StructureClassRec ← [
characteristic: ClassCharacteristic,
isElementOf: AC.defaultElementOfProc,
completeField: TRUE,
realField: FALSE,
realClosedField: FALSE,
algebraicallyClosedField: TRUE,
] ];
ComplexClass: Object ← AC.MakeClass["ComplexClass", NIL, NIL];
Complexes: PUBLIC Object ← AC.MakeStructure["Complexes", ComplexClass, NIL];
ComplexOne: Complex ← FromPairREAL[1.0, 0.0]; -- do after Complexes set
ComplexZero: Complex ← FromPairREAL[0.0, 0.0];
categoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← field], NIL, "category"];
groundStructureMethod: Method ← AC.MakeMethod[Value, FALSE, NIL, NIL, "groundStructure"];
shortPrintNameMethod: Method ← AC.MakeMethod[ToRopeOp, FALSE, NEW[AC.ToRopeOp ← ShortPrintName], NIL, "shortPrintName"];
recastMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Recast], NIL, "recast"];
canRecastMethod: Method ← AC.MakeMethod[BinaryPredicate, TRUE, NEW[AC.BinaryPredicate ← CanRecast], NIL, "canRecast"];
legalFirstCharMethod: Method ← AC.MakeMethod[LegalFirstCharOp, FALSE, NEW[AC.LegalFirstCharOp ← LegalFirstChar], NIL, "legalFirstChar"];
readMethod: Method ← AC.MakeMethod[ReadOp, FALSE, NEW[AC.ReadOp ← Read], NIL, "read"];
fromRopeMethod: Method ← AC.MakeMethod[FromRopeOp, TRUE, NEW[AC.FromRopeOp ← FromRope], NIL, "fromRope"];
toRopeMethod: Method ← AC.MakeMethod[ToRopeOp, FALSE, NEW[AC.ToRopeOp ← ToRope], NIL, "toRope"];
toExprMethod: Method ← AC.MakeMethod[ToExprOp, FALSE, NEW[AC.ToExprOp ← ToExpr], NEW[AC.UnaryToListOp ← ComplexesDesired], "toExpr"];
complexMethod: Method ← AC.MakeMethod[BinaryOp, FALSE, NEW[AC.BinaryOp ← FromPairReal], NEW[AC.UnaryToListOp ← RealArgsDesired], "complex"];
zeroMethod: Method ← AC.MakeMethod[NullaryOp, FALSE, NEW[AC.NullaryOp ← Zero], NIL, "zero"];
oneMethod: Method ← AC.MakeMethod[NullaryOp, FALSE, NEW[AC.NullaryOp ← One], NIL, "one"];
parenMethod: Method ← AC.MakeMethod[UnaryOp, FALSE, NEW[AC.UnaryOp ← Paren], NIL, "paren"];
sumMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Add], NEW[AC.UnaryToListOp ← ComplexesDesired], "sum"];
negationMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Negate], NEW[AC.UnaryToListOp ← ComplexesDesired], "negation"];
differenceMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Subtract], NEW[AC.UnaryToListOp ← ComplexesDesired], "difference"];
productMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Multiply], NEW[AC.UnaryToListOp ← ComplexesDesired], "product"];
commutativeMethod: Method ← AC.MakeMethod[Value, FALSE, NIL, NIL, "commutative"];
powerMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Power], NEW[AC.UnaryToListOp ← ObjectAndIntDesired], "power"];
conjugateMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Conjugate], NEW[AC.UnaryToListOp ← ComplexesDesired], "conjugate"];
modulusMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Modulus], NEW[AC.UnaryToListOp ← ComplexesDesired], "modulus"];
invertMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Invert], NEW[AC.UnaryToListOp ← ComplexesDesired], "invert"];
fractionMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Divide], NEW[AC.UnaryToListOp ← ComplexesDesired], "fraction"];
equalMethod: Method ← AC.MakeMethod[BinaryPredicate, TRUE, NEW[AC.BinaryPredicate ← Equal], NEW[AC.UnaryToListOp ← ComplexesDesired], "equals"];
AC.AddMethodToClass[$category, categoryMethod, ComplexClass];
AC.AddMethodToClass[$groundStructure, categoryMethod, ComplexClass];
AC.AddMethodToClass[$shortPrintName, shortPrintNameMethod, ComplexClass];
AC.AddMethodToClass[$recast, recastMethod, ComplexClass];
AC.AddMethodToClass[$canRecast, canRecastMethod, ComplexClass];
AC.AddMethodToClass[$legalFirstChar, legalFirstCharMethod, ComplexClass];
AC.AddMethodToClass[$read, readMethod, ComplexClass];
AC.AddMethodToClass[$fromRope, fromRopeMethod, ComplexClass];
AC.AddMethodToClass[$toRope, toRopeMethod, ComplexClass];
AC.AddMethodToClass[$toExpr, toExprMethod, ComplexClass];
AC.AddMethodToClass[$complex, complexMethod, ComplexClass];
AC.AddMethodToClass[$zero, zeroMethod, ComplexClass];
AC.AddMethodToClass[$one, oneMethod, ComplexClass];
AC.AddMethodToClass[$paren, parenMethod, ComplexClass];
AC.AddMethodToClass[$sum, sumMethod, ComplexClass];
AC.AddMethodToClass[$negation, negationMethod, ComplexClass];
AC.AddMethodToClass[$difference, differenceMethod, ComplexClass];
AC.AddMethodToClass[$product, productMethod, ComplexClass];
AC.AddMethodToClass[$commutative, commutativeMethod, ComplexClass];
AC.AddMethodToClass[$pow, powerMethod, ComplexClass];
AC.AddMethodToClass[$conjugate, conjugateMethod, ComplexClass];
AC.AddMethodToClass[$modulus, modulusMethod, ComplexClass];
AC.AddMethodToClass[$invert, invertMethod, ComplexClass];
AC.AddMethodToClass[$fraction, fractionMethod, ComplexClass];
AC.AddMethodToClass[$eqFormula, equalMethod, ComplexClass];
AC.InstallStructure[Complexes];
AC.SetSuperClass[Reals.Reals, Complexes];