TypeScript (and Flow probably?) might be the biggest industry adopters of typestate so far.
-
-
-
Replying to @samth
I guess I mean when the type of a variable can vary depending on control flow.
1 reply 0 retweets 2 likes -
e.g. “let foo: A | B = …; if (!(foo instanceof B)) { /* foo statically has type A in here */ } /* but here it’s A | B */
3 replies 0 retweets 2 likes -
fwiw Go does this too in interface switches. No explicit cast necessary
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @pcwalton
Neat! When did they add that (and can you point to the docs on it)?
2 replies 0 retweets 1 like -
Been there like forever? https://tour.golang.org/methods/16 Only works for switch, can't do it in an if
3 replies 0 retweets 0 likes
I wouldn’t consider that the same thing because it operates on a lexical basis not a CFG basis
-
-
Heh, we actually had the equivalent (lexical) thing being suggested for Rust, for variant types and/or GADT.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.