Inline asm expressions for ranged integrals?

bearophile bearophileHUGS at lycos.com
Tue Dec 28 00:59:18 PST 2010


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 built-in.

I think currently D2 offers a good enough syntax to implement ranged integrals in a library.
There are some problems, like:
http://d.puremagic.com/issues/show_bug.cgi?id=4053
http://d.puremagic.com/issues/show_bug.cgi?id=4331

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:
http://www.dsource.org/projects/ldc/wiki/Docs#allow_inline

And "Inline Assembly Expressions":
http://www.dsource.org/projects/ldc/wiki/InlineAsmExpressions

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

Bye,
bearophile


More information about the Digitalmars-d mailing list