/* Test some permuations of type conversion - both numeric => String
 * conversions, as well as val => class conversions
 */
using namespace oadl;

class complex {
    var real, imag;
    public proc create(r,i)
    {
        real = r;
        if( nargs() > 1 ) {
            imag = i;
        }
        else {
            imag = 0;
        }
    }
    operator => (rhs) {
        if (rhs == String) {
            return "(" ## (real=>String) ## "," ## (imag=>String) ## ")";
        }
        else {
            return real => rhs;
        }
    }
    operator \=> (lhs) {
        return new complex(lhs);
    }
}

proc main()
{
    var a, b;
    a = new complex(1,2);
    b = Int(a);
    "B is: ", b, "\n";
    a = 3.14 => complex; // Use conversion rather than create
    "A is: ", String(a), "\n";
}