News for hackers. Stuff that matters.
Re:Resources about programming practices for writing safety-... by spc476 on Monday March 06, 2017 @10:59PM (#13808162)
A simple example would be instead of this:

    int temperature_a;
    int temperature_b;
or even:

    Temperature a;
    Temperature b;
you would have:

    Celsius a;
    Fahrenheit b;
And an assignment between a and b would be an error, as Celcius and Fahrenheit are different types. Going along this path then, if you can extend the type system enough:

    Yards width;
    Yards length;
    Acre  size = width * length; /* this would be okay */

    Yards width;
    Yards length;
    Yards height;
    Acre  money_bin = width * length * height; /* error */
    /* as acre is a measure of area, not volume */
Think of the type of calculations that the Unix command 'units' does, but built into a language instead of an application.
Re:Resources about programming practices for writing safety-... by dkersten on Tuesday March 07, 2017 @08:48AM (#13810241)
The Frink[1] language has units like this built in. Its pretty cool what you can do with it. I definitely agree that doing that or, at least, something like your code samples, is a good bug-avoidance idea.

[1] https://frinklang.org/