2 ms·
> Any idea as to why implicit casts aren't more supported in strictly typed languages? That's the difference between weakly and strongly typed. If you take a s
by dom0 9y ago
> Any idea as to why implicit casts aren't more supported in strictly typed languages?
That's the difference between weakly and strongly typed. If you take a strongly typed language, and add implicit casting, you get a weakly typed language.
How this is resolved (or if at all) depends a lot on the language. For example, in C++ it is straightforward to define implicit conversions (which can become confusing). In Python on the other hand, it is generally up to the receiver to call some kind of conversion function, like str(), which will use an object protocol (like __str__) on the instance. This is what print("foo", 1) does, or "foo %s" % 1.