> my Complex $c = 3+4i; > my $plain = 1.1; > $plain = $c; This might be even more "Complex" than that - what if Complex can be reduced? Should it? for instance:
my Complex $c = 3+4i; my Complex $d = 4i; my $plain = $c / $d; Does $plain get promoted, or does the result from the division get demoted? Should parrot bother to even check, or should it just promote automatically and let the implementation decide? I think promotion would be best and fastest for all circumstances. Perhaps there could be a sort of 'try' for conversion that returns the best possible result? for instance: my Complex $c = 3+4i; my Complex $d = <unknown qty>; my $plain = try_demote( $c / $d ); $plain now ISA Complex if it couldn't demote the result of the math, or it is an int if it could. Now if you need to know, then just check: $plain = $c / $d; # the '(or)'s here are alternate forms, not comparison if( $plain.ISA == "Complex" (or) $plain.Complex ){ print "It promoted!\n"; } elsif( $plain.ISA == "Scalar" (or) $plain.Scalar ) { print "Result was reduced!\n"; } Ramblings of a madman, Grant M.