On 10/01/13 19:56, Dicebot wrote:
> Definition of common type is pretty simple - it is a type both types can be 
> implicitly converted to.

It's a bit more complicated, even for the simple cases - for example two types
that implicitly convert to a narrower type can (and usually should) have a
different "common" type. In general, implicit conversions make things more
"interesting".

> For `int` and `BigInt` common type should be `BigInt` if it was possible to 
> define that implicit conversion. AFAIK it is not possible and thus they can't 
> have common type.

Yes. In practice, though, the required interface for these types may not require
the missing functionality (eg function calls won't work, but both construction
and assignment will - and this can be enough). The traits-like /hacks/ can be
useful then. That's of course just a work-around, not an argument against 
introducing
user defined implicit conversions.

artur

Reply via email to