Search code examples
dcompile-timecompile-time-constantrange-types

Ada-style Range Types in D


After having read this interesting article about Ada and C++ and knowing of D's support for CTFE and constant-parameter specialization of functions I wonder if Ada-Style Range types could be more easily/efficiently implemented in D than in C++. Has anybody perhaps already written such a library?

If such ranges could be implemented efficiently and developer-friendly in D it could be used as a promotor for establishing D in sectors with demands on determinism and type- and memory-safety (were D already shines) such as in avionics and automotive. D would thereby gain more developer-interest and stronger financial support.


Solution

  • I wrote some little code that does min and max of integers with overflow check:

    http://arsdnet.net/dcode/ranged.d

    This was just a proof of concept though, I doubt it will perform very well, but might if inlined.