3 ms·
> if you decide you are going to design a language where types are always coerced to perform operations instead of stopping execution when mismatched types are
by marcosdumay 11y ago
> if you decide you are going to design a language where types are always coerced to perform operations instead of stopping execution when mismatched types are encountered
Realistically, you've stop being sensible at this point.
If you insist on going that route, you'll need to define stuff like addition between an object and an array, and there is just no good way to do that.
Making your failure modes safe is a sensible choice. Attributing semantics to any character permutation a developer may throw at your compiler is not.
- emodendroket 11y agoThere are real advantages to doing this, especially when you consider the kind of stuff JS was originally intended for (for instance, non-programmers can write very simple JS that handles input text without having to understand a type system and parse strings as numbers).