3 ms·
This is a dynamically typed language, it has nothing in its static type system to distinguish between definitely-assigned values and optionally-assigned values.
by barrkel 6y ago
This is a dynamically typed language, it has nothing in its static type system to distinguish between definitely-assigned values and optionally-assigned values. That is, there's no way to tell the compiler that a variable or function parameter or return value is a T vs a Maybe<T> or Either<T,U>.
At best it could perform definite assignment analysis on variable declarations, but it can't go very far. In particular, it would do nothing for function return values.
As a result, the best it could give you is runtime errors when you e.g. access the value of a dynamic Maybe without checking for presence first. Without static analysis, this isn't hugely useful.
- fulafel 6y agoUninitialized variable access trapping at run time seems useful since it's likely an error. Some statically typed languages do comparable things too if their static TS is not very powerful, see eg trapping representations or IA64's NaT in C.