Start Code
IntClass: AC.StructureClass ← NEW[AC.StructureClassRec ← [
category: ring,
flavor: "Ints",
printName: ClassPrintName,
shortPrintName: ClassShortPrintName,
structureEqual: AC.defaultStructureEqualityTest,
characteristic: ClassCharacteristic,
isElementOf: AC.defaultElementOfProc,
legalFirstChar: ClassLegalFirstChar,
read: Read,
fromRope: FromRope,
toRope: ToRope,
write: Write,
toExpr: ClassToExpr,
toIndexRope: ToRope,
add: Add,
negate: Negate,
subtract: Subtract,
zero: ClassZero,
multiply: Multiply,
commutative: TRUE,
one: ClassOne,
equal: Equal,
ordered: TRUE,
sign: Sign,
abs: Abs,
compare: Compare,
integralDomain: TRUE,
gcdDomain: TRUE,
gcd: Gcd,
euclideanDomain: TRUE,
remainder: Remainder,
] ];
intsClass: Object ← AC.MakeClass["intsClass", NIL, NIL];
Ints: PUBLIC Object ← AC.MakeStructure["Ints", intsClass, NIL];
IntOne: Int ← FromINT[1]; -- Do after Ints set, so structure field gets nonNIL value
IntZero: Int ← FromINT[0];
categoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← ring], 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"];
toExprMethod: Method ← AC.MakeMethod[ToExprOp, FALSE, NEW[AC.ToExprOp ← ToExpr], NEW[AC.UnaryToListOp ← IntsDesired], "toExpr"];
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"];
fromINTMethod: Method ← AC.MakeMethod[FromINTOp, FALSE, NEW[AC.FromINTOp ← FromINT], NIL, "fromINT"];
integerMethod: Method ← AC.MakeMethod[FromRopeOp, FALSE, NEW[AC.FromRopeOp ← FromRope], NIL, "integer"];
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 ← IntsDesired], "sum"];
negationMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Negate], NEW[AC.UnaryToListOp ← IntsDesired], "negation"];
differenceMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Subtract], NEW[AC.UnaryToListOp ← IntsDesired], "difference"];
productMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Multiply], NEW[AC.UnaryToListOp ← IntsDesired], "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"];
euclideanDomainMethod: Method ← AC.MakeMethod[Value, FALSE, NIL, NIL, "euclideanDomain"];
remainderMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Remainder], NEW[AC.UnaryToListOp ← IntsDesired], "remainder"];
gcdMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Gcd], NEW[AC.UnaryToListOp ← IntsDesired], "gcd"];
totientMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Totient], NEW[AC.UnaryToListOp ← IntsDesired], "totient"];
dividesMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Divides], NEW[AC.UnaryToListOp ← IntsDesired], "divides"];
equalMethod: Method ← AC.MakeMethod[BinaryPredicate, TRUE, NEW[AC.BinaryPredicate ← Equal], NEW[AC.UnaryToListOp ← IntsDesired], "equals"];
orderedMethod: Method ← AC.MakeMethod[Value, FALSE, NIL, NIL, "ordered"];
signMethod: Method ← AC.MakeMethod[CompareToZeroOp, TRUE, NEW[AC.CompareToZeroOp ← Sign], NEW[AC.UnaryToListOp ← IntsDesired], "sign"];
absMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Abs], NEW[AC.UnaryToListOp ← IntsDesired], "abs"];
compareMethod: Method ← AC.MakeMethod[BinaryCompareOp, TRUE, NEW[AC.BinaryCompareOp ← Compare], NEW[AC.UnaryToListOp ← IntsDesired], "compare"];
testLoop: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← TestLoop], NEW[AC.UnaryToListOp ← IntsDesired], "testLoop"];
AC.AddMethodToClass[$category, categoryMethod, intsClass];
AC.AddMethodToClass[$groundStructure, categoryMethod, intsClass];
AC.AddMethodToClass[$shortPrintName, shortPrintNameMethod, intsClass];
AC.AddMethodToClass[$recast, recastMethod, intsClass];
AC.AddMethodToClass[$canRecast, canRecastMethod, intsClass];
AC.AddMethodToClass[$toExpr, toExprMethod, intsClass];
AC.AddMethodToClass[$legalFirstChar, legalFirstCharMethod, intsClass];
AC.AddMethodToClass[$read, readMethod, intsClass];
AC.AddMethodToClass[$fromRope, fromRopeMethod, intsClass];
AC.AddMethodToClass[$toRope, toRopeMethod, intsClass];
AC.AddMethodToClass[$integer, integerMethod, intsClass];
AC.AddMethodToClass[$fromINT, fromINTMethod, intsClass];
AC.AddMethodToClass[$zero, zeroMethod, intsClass];
AC.AddMethodToClass[$one, oneMethod, intsClass];
AC.AddMethodToClass[$paren, parenMethod, intsClass];
AC.AddMethodToClass[$sum, sumMethod, intsClass];
AC.AddMethodToClass[$negation, negationMethod, intsClass];
AC.AddMethodToClass[$difference, differenceMethod, intsClass];
AC.AddMethodToClass[$product, productMethod, intsClass];
AC.AddMethodToClass[$commutative, commutativeMethod, intsClass];
AC.AddMethodToClass[$pow, powerMethod, intsClass];
AC.AddMethodToClass[$euclideanDomain, euclideanDomainMethod, intsClass];
AC.AddMethodToClass[$remainder, remainderMethod, intsClass];
AC.AddMethodToClass[$gcd, gcdMethod, intsClass];
AC.AddMethodToClass[$totient, totientMethod, intsClass];
AC.AddMethodToClass[$divides, dividesMethod, intsClass];
AC.AddMethodToClass[$eqFormula, equalMethod, intsClass];
AC.AddMethodToClass[$ordered, orderedMethod, intsClass];
AC.AddMethodToClass[$sign, signMethod, intsClass];
AC.AddMethodToClass[$abs, absMethod, intsClass];
AC.AddMethodToClass[$compare, compareMethod, intsClass];
AC.AddMethodToClass[$testLoop, testLoop, intsClass];
AC.InstallStructure[Ints];