Section2.10

]>
Book Contents Previous Section 2.9 Package Calling and Target Types Next Section 2.11 Exposing Domains and Packages Book Index

## 2.10 Resolving Types

In this section we briefly describe an internal process by which resolve Axiom determines a type to which two objects of possibly different types can be converted. We do this to give you further insight into how Axiom takes your input, analyzes it, and produces a result.

What happens when you enter x+1 to Axiom? Let's look at what you get from the two terms of this expression.

This is a symbolic object whose type indicates the name.

x

x

Type: Variable x

This is a positive integer.

1

1

Type: PositiveInteger

There are no operations in PositiveInteger that add positive integers to objects of type Variable(x) nor are there any in Variable(x). Before it can add the two parts, Axiom must come up with a common type to which both x and 1 can be converted. We say that Axiom must resolve the two types into a common type. In this example, the common type is Polynomial(Integer).

Once this is determined, both parts are converted into polynomials, and the addition operation from Polynomial(Integer) is used to get the answer.

x + 1

x+1

Type: Polynomial Integer

Axiom can always resolve two types: if nothing resembling the original types can be found, then Any is be used. Any This is fine and useful in some cases.

["string",3.14159]

["string",3. 14159]

Type: List Any

In other cases objects of type Any can't be used by the operations you specified.

"string" + 3.14159
There are 11 exposed and 5 unexposed library operations named +
having 2 argument(s) but none was determined to be applicable.
Use HyperDoc Browse, or issue
)display op +
to learn more about the available operations. Perhaps
package-calling the operation or using coercions on the
arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named +
with argument type(s)
String
Float
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.

Although this example was contrived, your expressions may need to be qualified slightly to help Axiom resolve the types involved. You may need to declare a few variables, do some package calling, provide some target type information or do some explicit conversions.

We suggest that you just enter the expression you want evaluated and see what Axiom does. We think you will be impressed with its ability to ``do what I mean.'' If Axiom is still being obtuse, give it some hints. As you work with Axiom, you will learn where it needs a little help to analyze quickly and perform your computations.

Book Contents Previous Section 2.9 Package Calling and Target Types Next Section 2.11 Exposing Domains and Packages Book Index