|
|
|
|
|
by vlasta2
4979 days ago
|
|
I believe the example ("abc" + 123) given in the article is not 100% correct. Let's take C++ as a statically typed language and define a custom class MegaType. Then, in the whole program, we may use only variables of this single type. Any program can be trivially transformed to use just this single type. The piece of code would then look like MegaType("abc") + MegaType(123). When executed, it would behave exactly as a language with dynamic types. So, a dynamically typed language really is a specialization of statically typed language - you only need to define and use this one MegaType and implement all needed operators for this type (and they may of course work differently in runtime: "123" + 123 may result in 246 if you decide it should). |
|