News for hackers. Stuff that matters.
Re:Why Use Pascal? by Jtsummers on Saturday July 08, 2023 @06:24PM (#36649379)
Try that line in both Python and Perl and see how they behave, you'll see that one (Python) respects types (the most useful notion of "strong typing" is no or limited automatic type coercion and "weak typing" as an excessive permissibility around mixing of types in operations) and the other (Perl) does not.

I pointed out the OCaml example because both you and your sibling poster brought up type declarations as somehow mattering with respect to "strong typing". OCaml doesn't require type declarations, so I guess it's weakly typed according to both of you. Which is a surprising result.

Re:Why Use Pascal? by slt2021 on Saturday July 08, 2023 @06:28PM (#36649404)
I never do 1+”1” in my code, so this example is not useful to me.

I do however annotate types and expect Python to respect type annotations which is not the case. Then I dont understand what is point of annotating types if they are not respected?

If your argument that Python doesn’t convert from one type to another - well, it doesn’t need to do that if doesn’t care about types in the first place and lets you pass any junk into any method (and this is #1 thing that type system is supposed to prevent)

Is it only for documentation so that people reading code could understand what types to pass?

Re:Why Use Pascal? by dsemi on Saturday July 08, 2023 @06:33PM (#36649440)
Python type annotations were added to be used by an external type checker, so no they are not enforced by the interpreter itself.

This was an explicit decision: https://peps.python.org/pep-0484/#non-goals

Re:Why Use Pascal? by TheCleric on Saturday July 08, 2023 @06:52PM (#36649575)
Python type hinting is not useful at runtime (in fact it's flat out ignored). It is useful at "linting" time when run through mypy.