EuCANOOP

Adding your own types

The following steps are necessary to define your own EuCANOOP types.

Define the checking routine

Write a function which checks the type you wish to establish. I use the convention "is_typename". So, for example my is_integer function reads:
global function is_integer(object i)
    if not integer(i) then
        return FALSE
    else
        return integer(i)
    end if
end function

Define the EuCANOOP type

To declare the type in EuCANOOP simply associate a constant with the routine_id of the checking routine. In the above example this would read as:
constant INTEGER = routine_id("is_integer")
Make the constant global if you wish to pass it on!

Define the type in Euphoria

Often you want to use the corresponding type in standard Euphoria. If so, then simply define the type by calling the routine.

If the checking routine is, say is_mytype then define mytype as

type mytype(object mt)
    return is_mytype(mt)
end type
Likewise make the type global if you wish to pass it on!