3 ms·
I would like to have a language with a scalable type system. That means the type system should accommodate everything from dynamic typing for quick hacks, all t
by nradov 17y ago
I would like to have a language with a scalable type system. That means the type system should accommodate everything from dynamic typing for quick hacks, all the way to finely-grained static typing suitable for safety-critical systems.
For example, a particular variable's typed might be refined over time in stages like this.
1. dynamically typed
2. number
3. floating-point number
4. floating-point number between 0.0 - 100.0
5. floating-point number between 0.0 - 100.0, with a minimum of 40 bits in the fractional part
6. floating-point number between 0.0 - 100.0, with a minimum of 40 bits in the fractional part, and tell the execution environment to optimize for memory use instead of performance
The languages in use today can cover parts of that spectrum, but nothing allows the whole range.
- sb 17y agoAFAIR/CT the following paper might be of interest to you: Jeremy Siek, Walid Taha: "Gradual Typing for Functional Languages", 2006 http://www.cs.colorado.edu/~siek/pubs/pubs/2006/siek06:_gradual.pdf http://www.cs.colorado.edu/~siek/pubs/pubs/2006/siek06:_grad...
- anamax 17y agoType systems that are concerned with representation and range of primitive values aren't very useful. Replacing representation/structure with type names doesn't improve things. If I'm adding 3.5 oz of OJ to 6.7 oz of vodka, that's either a programming mistake or a strong drink (represented programatically). (Yes, the correct answer depends on context.) A type system that helps me in that situation is worth something. A type system that only addresses representation and range of primitive values can't even begin to help in that situation. Yes, units are a partial solution. (They also reduce programmer work - you can add feet to furlongs and get something sensible.)
- nradov 17y agoAgreed. I just used that floating-point variable as a simple example. It would certainly be useful to have some concept of units built into the language. I'm actually working on handling units in Java right now, as part of a larger library for healthcare data. http://www.hl7.org/v3ballot/html/infrastructure/datatypes/datatypes.htm#prop-PQ.unit http://www.hl7.org/v3ballot/html/infrastructure/datatypes/da...
- jongraehl 17y agoGood point. However, if "list of no fewer than 1 strings" is an interesting type, then why can't "integer no smaller than 1" be an interesting type?