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

let's talk about qi

Name: Anonymous 2015-02-09 4:09

https://en.wikipedia.org/wiki/Qi_(programming_language)

Copy pasted example of defining a type for a sorted list.

(12+) (datatype ordering

if (number? X)
if (number? Y)
let Z (* X 2)
if (= Y Z)
__________________
[X Y] : ordering;)
ordering : unit

(13+) [2 3] : ordering
error: type failure

(14+) [2 4] : ordering
[2 4] : ordering

Name: Anonymous 2015-02-12 19:59

>>49
The purpose of a type system isn't to catch all your mistakes automatically. It's to allow you to define up-front what a certain kind of mistake in your logic is. At the basic level the standard library does a little bit of this for you, but you have to write your own types to extend that to the logic of your own program.

You can make mistakes while defining the types but the types are only a small part of the logic, and easier to get right. Doing this will allow the compiler to check important parts of the rest of your logic.

>>50
You are too attached to this one benefit of type safety to see the point. If you don't write your own types and put thought into them, the logic you write is no more likely to be correct than if you wrote it in JavaScript with a linter.

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