News for hackers. Stuff that matters.
Re:Python's Type Checking Renaissance by jgwil2 on Wednesday January 27, 2021 @09:05AM (#25928379)
Okay, so it's union types plus pattern matching that are missing (among other things I'm sure). Thanks, that's helpful.

> You cannot safely "match" on the command in the same way you can in other languages, because the compiler doesn't know that there are only exactly 3 types of commands.

Perhaps the visitor pattern? Command processing receives an object and calls its command method, which knows what permissions it has.

I guess the fact that I have to keep saying "patterns" is a hint that some flexibility is missing. Still, I'd rather have Java/C++ static types than nothing at all.

Re:Python's Type Checking Renaissance by dwohnitmok on Wednesday January 27, 2021 @03:48PM (#25933726)
Yes the visitor pattern is a valid encoding of algebraic datatypes. Very heavyweight (imagine if booleans were all encoded with the visitor pattern) but nonetheless valid.

https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/