gmpxx implicit conversion between types
arndt at jjj.de
Wed Mar 9 08:58:01 CET 2011
* Torbjorn Granlund <tg at gmplib.org> [Mar 08. 2011 20:27]:
> Marc Glisse <marc.glisse at inria.fr> writes:
> There is 0 effect on libgmpxx. Yes, it only affects source
> compatibility. Some (very questionable) code will stop
> compiling. Other than that, I don't think it can break anything, even
> if linking together .o files from before and after the change.
> Ok, should we allow any implicit conversions between GMP types? I think
> C's type conversions are actively harmful, but C++ has done some cleanup
> in this area with which I am only vaguely.
> When dealing with "heavy" types like these, is it in the C++ spirit to
> allow implicit conversions? Will we do any good by disallowing them?
Implicit: as few as possible.
A good guidance are computer algebra systems. E.g.:
Divide an integer by an integer ==> rational
Any operation of type with float ==> float.
About signed/unsigned integers:
a problem in C (with one bit used as sign
or plain bit, depending on type), should not
be a problem for gmp where unsigned should
be a proper "subtype" of signed.
Obviously explicit conversions should exist
from any type to any type (where possible).
Another thing (if not already done):
make _all_ constructors "explicit".
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
More information about the gmp-discuss