Made with KolourPaint and screenshots from Kate (with the GitHub theme).

  • barsoap@lemm.ee
    link
    fedilink
    arrow-up
    17
    arrow-down
    1
    ·
    edit-2
    7 hours ago

    The actual reason why let … in syntax tends to not use C-style “type var” like syntax is because it’s derived from the syntax type theory uses, and type theorists know about parameterised types. Generics, in C++ parlance, excuse my Haskell:

    let foo :: Map Int String = mempty

    We have an empty map, and it maps integers to Strings. We call it foo. Compare:

    Map Int String foo = mempty

    If nothing else, that’s just awkward to read and while it may be grammatically unambiguous (a token is a name if it sits directly in front of =) parser error messages are going to suck. Map<Int,String> is also awkward but alas that’s what we’re stuck with in Rust because they reasoned that it would be cruel to put folks coming from C++ on angle bracket withdrawal. Also Rust has ML ancestry don’t get me started on their type syntax.

    • weird@sub.wetshaving.social
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      7 hours ago

      There is also the thing where the compiler might mistake your c++ style variable declaration for a function, e.g.

      String myfunction():

      String myvariable();