News for hackers. Stuff that matters.
Re:Where Do Type Systems Come From? by catnaroek on Saturday July 08, 2017 @04:45PM (#14727112)
> Why is that required?

Say, because you want to use that reference cell in two different threads.

Re:Where Do Type Systems Come From? by evincarofautumn on Saturday July 08, 2017 @08:44PM (#14727855)
I think I see what you’re getting at. If I create an empty mutable list and send a reference to it to two different threads A and B, where A adds an integer to the list and B adds a string, then it’s nondeterministic which thread raises a type error.

And degrading the type to a union (int ∨ string) as I mentioned is still nondeterministic even though unions form a lattice—I can recover determinism when writing to the list in both A and B, but supposing A writes first, B writes second, and then A reads expecting only integers, it gets a type error because it hasn’t checked for the string case.

But I’d argue that 1. this is bad form and you want a type error somewhere and 2. you have this problem already with type-changing mutable references in a dynamically typed multithreaded language. (Say just “int” and “string” instead of “list of int” and “list of string”.)

Re:Where Do Type Systems Come From? by catnaroek on Saturday July 08, 2017 @10:53PM (#14728134)
I need a container type that can be empty, because I need the monomorphic type of the cell to be undecided until the reference has been handed out to the worker threads.
Re:Where Do Type Systems Come From? by johncolanduoni on Sunday July 09, 2017 @12:16AM (#14728338)
If your program doesn't have a race condition, then you're fine. And if it does, then the list being monomorphic is not going to help (try your scenario with a C++ vector or Java ArrayList).
Re:Where Do Type Systems Come From? by johncolanduoni on Saturday July 08, 2017 @11:39PM (#14728229)
If your standard for a possible programming language that supports concurrency is that no data races are possible, then there's very few languages to be had.
Re:Where Do Type Systems Come From? by catnaroek on Sunday July 09, 2017 @12:20AM (#14728349)
This particular discussion wasn't about ruling out data races (although, of course, that is important too). It was about ruling out trying to read a list of strings from a reference cell containing a list of ints.
Re:Where Do Type Systems Come From? by johncolanduoni on Sunday July 09, 2017 @12:40AM (#14728399)
You're the one who brought up threads as a reason runtime monomorphisation doesn't work. If access to the list is properly synchronized, then what I proposed works just fine (you get your runtime error in whatever thread accesses the list second). If it's not, then unless you're using a concurrent data structure you're already screwed. The type system will at most change exactly how you get screwed.