Oriel Jutty :hhHHHAAAH:

Indoor European. I know #regex. I write #code (in #C or #Haskell or #Perl or #JavaScript or #bash). 100% OPSEC.

  • 0 Posts
  • 16 Comments
Joined 3 years ago
cake
Cake day: November 6th, 2022

help-circle
  • I believe now it is my turn to say you’re spewing nonsense. Have you ever used a language with a type system? Because this whole idea of “testing external data to see if it is the right type” doesn’t really make sense.

    At the lowest layer, generally, external data is an array of bytes. It has no other type you could “test”. However, you can decode or parse it into a form that makes sense for your program. And why couldn’t I cleanly recover from parse errors? (And how do you think Python does it?)


  • Again, “strong types” doesn’t mean anything.

    But from a type theory perspective, having “dynamic types” absolutely means you don’t have a type system. All Python has is runtime exceptions. The fact that one of them is named TypeError doesn’t make it a type error in the formal sense.

    The point of a type system is not that variables have types, but that types are assigned to expressions (i.e. pieces of code in your source file), not to values (i.e. pieces of data). This is important because it guarantees that certain errors cannot occur in a program that passes the type checker (assuming you have a sensible/useful type system). And you get this assurance without running a single line of code.

    To get a similar guarantee from Python, you need to write exhaustive tests, just as with any other runtime error.














  • Both of those declarations look weird to me. In Haskell it would be:

    a :: Stringbob :: (String, Int, Double) -> [String]bob (a, b, c) = ...
    

    … except that makes bob a function taking a tuple and it’s much more idiomatic to curry it instead:

    bob :: String -> Int -> Double -> [String]bob a b c = ...-- syntactic sugar for:-- bob = \a -> \b -> \c -> ...
    

    The [T] syntax also has a prefix form [] T, so [String] could also be written [] String.

    OCaml makes the opposite choice. In OCaml, a list of strings would be written string list, and a set of lists of strings would be string list set, a list of lists of integers int list list, etc.