www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Inline asm expressions for ranged integrals?

reply bearophile <bearophileHUGS lycos.com> writes:
The many things Andrei keeps explaining (teaching) me have changed the way I
desire the "ranged integrals" in D. Now I'd like means to implement "good
enough" library-defined ranged integrals in D2, instead of just having them

I think currently D2 offers a good enough syntax to implement ranged integrals
in a library.
There are some problems, like:

Another problem is that to implement efficient ranged integrals you need to
read the overflow and carry flags of the CPU. To do this efficiently I think
you need Asm instructions. But this kills inlining. And if you want to
implement a ranged integer then inlining is just necessary, otherwise you a
function call every time you want to sum two ranged integers.

The LDC compiler faces this problem in two ways, the allow_inline pragma:

And "Inline Assembly Expressions":

Is it good and possible to add some similar feature to D2? Is it possible to
fix bug 4331?

Dec 28 2010
parent bearophile <bearophileHUGS lycos.com> writes:
 Is it possible to fix bug 4331?
Sorry, I think fixing bug 4331 is not necessary to implement good enough ranged integrals. The out of range tests are enough inside the getter and setter properties. Bye, bearophile
Dec 28 2010