OT (partially): about promotion of integers

bearophile bearophileHUGS at lycos.com
Tue Dec 11 17:15:24 PST 2012


H. S. Teoh:

> Just because you specify a certain compiler switch, it can cause
> unrelated breakage in some obscure library somewhere, that 
> assumes modular arithmetic with C/C++ semantics.

The idea was about two switches, one for signed integrals, and 
the other for both signed and unsigned. But from other posts I 
guess Walter doesn't think this is a viable possibility.

So the solutions I see now are stop using D for some kind of more 
important programs, or using some kind of safeInt, and then work 
with the compiler writers to allow user-defined structs to be 
usable as naturally as possible as ints (and possibly 
efficiently).

Regarding safeInt I think today there is no way to write it 
efficiently in D, because the overflow flags are not accessible 
from D, and if you use inlined asm, you lose inlining in DMD. 
This is just one of the problems. The other problems are syntax 
incompatibilities of user-defined structs compared to built-in 
ints. Other problems are the probable lack of high-level 
optimizations done on such user defined type.

We are very far from a good solution to such problems.

Bye,
bearophile


More information about the Digitalmars-d mailing list