Why I chose D over Ada and Eiffel

Gour gour at atmarama.net
Thu Aug 29 06:33:21 PDT 2013


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;
type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); 
 
type Date is
   record
     Day   : Day_type;
     Month : Month_type;
     Year  : Year_type;
   end record;

subtype Working_Hours is Hours range 0 .. 12;           
subtype Working_Day is Weekday range Monday .. Friday;
 
Work_Load: constant array(Working_Day) of Working_Hours
   := (Friday => 6, Monday => 4, others => 10);


and ensure type-safety for such custom types?


Sincerely,
Gour

-- 
You have a right to perform your prescribed duty, but you
are not entitled to the fruits of action. Never consider 
yourself the cause of the results of your activities,
and never be attached to not doing your duty.

http://www.atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810



More information about the Digitalmars-d mailing list