Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Type system for dimensional units

Name: Anonymous 2012-02-25 15:48

Are there any programming languages that let you specify dimensional units as part of the type information? It would add to the analyzability of code at compile time.
Something like this:
type Second;
type Minute = 60 Second;
type Hour = 60 Minute;
type Meter;
type Mile = 1609.344 Meter;
type DegreeC;
type DegreeF = DegreeC * 9/5 + 32;
float(Meter/Second) mps = (Mile/Hour)60; // converts Miles/Hour into Meters/Second
float(Meter/Second) x = (Hour)60; // type error

Name: Anonymous 2012-02-25 19:46

Doesn't Ada allow you to define types like this?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List