News for hackers. Stuff that matters.
Re:Dependently Typed Programming by lobster_johnson on Tuesday July 01, 2014 @09:31PM (#7974583)
Pascal, and Pascal-derived languages such as Modula and Turbo Pascal, have this:

    type Age = 1..199;
A value of type Age can only have the values 1 <= x <= 199, and can't be assigned to non-Age variables. Enums belong to this category of ordinal types.

In Ada:

    type Age is Range 1 .. 199;
    type Temperature is new Integer Range 32 .. 212;

    a: Age; t: Temperature
    a := t  -- this fails at compile time
Ada 2012 adds the support for specifying Eiffel-style contracts, but on types:

    subtype Even is Integer
      with Dynamic_Predicate => Even mod 2 = 0;
You can't assign an odd number to a variable of type Even.
Re:Dependently Typed Programming by mamcx on Wednesday July 02, 2014 @01:48PM (#7978431)
Yep, I know about pascal (my 2d language after foxpro) but not the ADA 2012.

The Dynamic_Predicate is on runtime or compile time? If assign a:Int = Even, I need to be explicit and do a convert (I imagine is yes, that is the pascal style but not have experience with ADA)

Re:Dependently Typed Programming by lobster_johnson on Friday July 04, 2014 @09:03PM (#7990721)
I believe it occurs only at compile time if it is possible for the compiler to evaluate the check; otherwise it's done at runtime.