Promoting to Complex

Patrick R. Michaud pmichaud at pobox.com
Mon Sep 27 18:04:26 UTC 2010


On Mon, Sep 27, 2010 at 01:12:41PM -0400, Andrew Whitworth wrote:
> I'm fine with the idea of not automatically promoting to "bigger"
> types in general, but that's not really consistent with what Parrot
> already does. As Paul pointed out, Float already promotes to BigNum
> and Integer already promotes to BigInt where required. Integer also
> autopromotes to Float in some occasions.

To me, promoting Integer to BigInt is of a different nature than
autopromoting a Float operand to a Complex result.  In the case of 
Integer->BigInt, the result still have the same semantic operations 
and meanings for integers -- we're simply changing the range/representation 
of the integer type.  In the case of a Float operation returning a Complex 
result, the Complex PMC has some substantially different behaviors from
Floats -- stringification being one of the more immediate and obvious ones.

While I'm in favor of consistency; there are often several different 
flavors of consistency to choose from.  :-)

I'm not strongly opposed to autopromoting Float to Complex; I just know
that in Rakudo's case this behavior would be a pain to deal with, requiring
that we create custom PMC types that don't have the autopromoting behavior.

Pm


More information about the parrot-dev mailing list