What would a minimal subset of D look like?
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Jun 22 09:42:48 UTC 2019
On Saturday, 22 June 2019 at 09:25:58 UTC, Yatheendra wrote:
> I'm no embedded programmer, but a possible addition (not
> removal) might be statically proving bounds safety &
> reduce/avoid runtime bounds checking on array access; can D or
> Rust do that? Ada should be able to, with its integer range
> types. Actually it will have benefits beyond embedded as
> disabling bounds checking in release builds would no longer be
> justifiable.
No, D can't. There are languages that can do it, or languages
with tooling and annotations that can do it. I believe SPARK
(derived from Ada) and some C-extension have such tooling
available.
AFAIK this is generally done by establishing an upper bound on
the number of iterations you can have in a loop and then
conceptually "unrolling" the loop up to that point (so that there
is no for and while, just a long series of if-statements) and
then using a prover that will then prove that the array bounds
cannot be exceeded.
It might be possible in some cases for the prover to establish
this without an upper bound too, but as far as I understand, in
practice you often have to provide an upper bound.
Ola.
More information about the Digitalmars-d
mailing list