26 ms·
> How to make your language predictable: > 1. Variables should not be allowed to change their type. Completely disagree.
by hawleyal 12y ago
> How to make your language predictable:
> 1. Variables should not be allowed to change their type.
Completely disagree.
- mannykannot 12y agoThe author presented an argument for this proposition. Do you have an argument against it?
- hawleyal 12y agoEven JavaScript, which is much maligned for it's poor implementation of dynamic typing, has clear rules for type coercion. In the author's example in support of "Variables should not be allowed to change their type," the variable "x" is subject to coercion, but the real problem was poor scoping by using the global value instead of the parameter. This would be the same scoping problem, even if the variable type was not changed. Any non-deterministic function that modifies existing state can be said to produce unexpected/unpredictable/unreasonable results. In this case, the unpredictability was not due to a variable changing type.