4 ms·
The type of x is Int|String The type of (+ 1) is Int -> Int The type of y is Int Because x is of type Int|String and it's passed to a function that can only
by jrockway 15y ago
The type of x is Int|String
The type of (+ 1) is Int -> Int
The type of y is Int
Because x is of type Int|String and it's passed to a function that can only operate on Int, the program fails to compile.
- kingkilr 15y agoI highly reccomend you read, "Localized type inference of atomic types in python" by Brett Cannon (2005), it shines a light on just how much this doesn't work.
- ned_batchelder 15y agoSo when you said, "looks just like Python," you literally meant, "lexically looks like Python," because you aren't building a language that works just like Python.