Why I chose D over Ada and Eiffel

Piotr Szturmaj bncrbme at jadamspam.pl
Thu Aug 29 11:08:34 PDT 2013


W dniu 29.08.2013 15:33, Gour pisze:
> On Sun, 25 Aug 2013 17:06:27 +0200
> "bearophile" <bearophileHUGS at lycos.com> wrote:
>
>> Probably working even more you can make the D entry a bit more
>> statically safe (eventually you could reach the level of Ada code) but
>> the amount of work and code becomes excessive, and the resulting D
>> code becomes unnatural, and rather not idiomatic.
>
> Still considering whether to focus on Ada or D for my project, I wonder
> if D can do stuff like (from wikipedia page):
>
> type Day_type   is range    1 ..   31;
> type Month_type is range    1 ..   12;
> type Year_type  is range 1800 .. 2100;
> type Hours is mod 24;

These are refinement types (I call them 'views') and I have half-written 
DIP for this. However, I doubt that it will be accepted.

I would rather enable 'View pattern' by allowing contracts and 
invariants in release mode.

They still could be prepended with debug directive to establish the old 
behaviour:

struct S {
     debug invariant() { ... }
}

void fn()
debug in
{
     ...
}
debug out(result)
{
     ...
}
body
{
     ...
}


More information about the Digitalmars-d mailing list