3 ms·
That is absolutely not how Python works. Python values are typed.
by remram 2y ago
That is absolutely not how Python works. Python values are typed.
- apgwoz 2y ago> "a dynamically typed language is a statically typed language with only one static type." — Bob Harper
- remram 2y agoYes but we are not talking about static types...
- apgwoz 2y agoYou’re misunderstanding. Dynamic languages inherently have a single type that is checked _at runtime_. Store it in a string, store it in a struct. It doesn’t matter.
- layer8 2y agoThe runtime values have tags that denote their runtime type. They are not of a single type. You are talking about static types.
- apgwoz 2y agoAnd in Tcl the runtime type is computed at time of use. An optimized Tcl could cache an integer with a string that represents an int to avoid that cost. Nevertheless, a runtime type tag is an optimization. That doesn’t make Bob’s statement any less true.
- remram 2y agoWhat you said above is correct but is not related to what was being discussed before.
- apgwoz 2y agoHow is it not related? Because Python is “strong typed” vs “weak typed” for Tcl? $ tclsh8.6 % expr 1 + 2 3 % expr 3 + “hey there” invalid bareword “hey” in expression “1 + hey there”; should be “$hey” or “{hey}” or “hey(…)” or … vs. $ python3.11 >>> 1 + 2 3 >>> 1 + “hey there” Traceback (most recent call last): File “<stdin>”, line 1, in <module> TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’ I don’t really see a difference. Both checked types at runtime. Clearly Tcl can check types at runtime, even though it represents everything as a string. Whether all commands do so is another story. But, not all functions in Python check types before trying to do things that don’t make sense, either. So…
- eadmund 2y ago> Python values are typed. So are Tcl values.