Previous: , Up: Types And Values   [Index]


4.3 Implicit Convertions

The aime interpreter will convert between types of similar nature or use when there is a type mismatch between the present and expected value.

Implicit convertions are only performed for function arguments and returns. No convertions are performed for operator arguments, references function arguments, etc.

Convertions are done between the numerical intrinsic types (‘cardinal’, ‘integer’ and ‘real’) and between the ‘object’ type and any other type.

See The Object Type.

For the:

integer abs(integer);
real exp(real);
integer min(integer, integer);
real pow(real, real);

functions, all the:

    abs(7.5)
    abs(8z)
    abs(exp(0))
    exp(-2)
    exp(0z)
    min(2.5, -2.5)
    min(3, 3z)
    pow(0, 2)
    pow(8z, -2)
    pow(17, -.5)

calls are allowed.

Functions like:

void l_append(list, object);
void __object(object);

may be called with arguments of any type:

    __object(0);
    __object("all mine");
    __object(sin(3));
    __object(__object);
    l_append(l, 1001);
    l_append(l, "ich");
    l_append(l, l);
    l_append(l, exp);

All the:

real
convert_1(void)
{
    return 2;
}
integer
convert_2(cardinal c)
{
    return c;
}
object
convert_3(void)
{
    return 4;
}
integer
convert_4(object o)
{
    return o;
}

function definitions are allowed. The ‘object’ to ‘integer’ convertion in ‘convert_4’ will fail at run time if o holds no ‘integer’ convertible data.

Many of the functions exported by aime libraries accompanying the interpreter will also convert between related types.

See Byte Data Converters.