• fubo@lemmy.world
    link
    fedilink
    arrow-up
    74
    arrow-down
    2
    ·
    10 months ago

    Fortran, really.

    In Fortran, variables beginning with the letters i through n have integer type by default, whereas all other letters imply a real-number (floating-point) variable. You can change this by declaring a type, but using i for a real is non-obvious.

    (Hence the old joke, “God is real — unless declared integer.”)

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      34
      arrow-down
      2
      ·
      edit-2
      10 months ago

      idk, this arbitrary i-n range behaving differently than other variables sounds like a terrible source of weird bugs to me. I don’t think variable names should ever change a program’s behavior.

      edit:

      Many old Fortran 77 programs uses these implicit rules, but you should not! The probability of errors in your program grows dramatically if you do not consistently declare your variables.

      source

      • Successful_Try543@feddit.de
        link
        fedilink
        arrow-up
        29
        ·
        10 months ago

        This comes from early years, when FORTRAN was introduced and the programmers needed to save space in the punch cards. Today, to avoid this possible source of bugs, you usually state “implicit none” in the preamble.

        • GregoryTheGreat@programming.dev
          link
          fedilink
          arrow-up
          20
          ·
          10 months ago

          So I’ve been an engineer doing code ports to newer versions of Fortran. I never knew why that was at the top of every file. Thank you.