5 ms·
Here is the most common definition of strong typing, and below it an assertion that "Smalltalk, Perl, Ruby, Python, and Self are all strongly typed". https://e
by hope-striker 7y ago
Here is the most common definition of strong typing, and below it an assertion that "Smalltalk, Perl, Ruby, Python, and Self are all strongly typed".
https://en.wikipedia.org/wiki/Strong_and_weak_typing#Implicit_type_conversions_and_%22type_punning%22 https://en.wikipedia.org/wiki/Strong_and_weak_typing#Implici...
- strbean 7y agoThat is quite a disingenuous quote... the actual content is: > Smalltalk, Perl, Ruby, Python, and Self are all "strongly typed" in the sense that typing errors are prevented at runtime and they do little implicit type conversion, but these languages make no use of static type checking: the compiler does not check or enforce type constraint rules. The term duck typing is now used to describe the dynamic typing paradigm used by the languages in this group. That is quite a qualified usage. The only feature distinguishing Python from Javascript here is that Python does less implicit type conversion (where it is reasonable v.s. where it is insane). In every other dimension it is the same.
- ric2b 7y agoDo you have an example of Python doing implicit type conversion?
- kragen 7y agoPython2 implicitly converts int to long and str to unicode: >>> 2**100 1267650600228229401496703205376L >>> 'x' + u'y' u'xy' All Pythons implicitly convert int to float and int or float to complex: >>> 1 + .5 1.5 >>> 2 * 3j 6j Methods like list.extend now, in recent versions of Python (since 2.1), accept arbitrary iterables rather than just lists; it's more debatable whether this is an “implicit type conversion” or not. >>> x = [3, 4]; x.extend((5, 6)); x [3, 4, 5, 6]
- strbean 7y agoThanks for the examples. I was mainly thinking of int-float conversion that is present in the vast majority of languages.