• stebo02@sopuli.xyz
    link
    fedilink
    arrow-up
    24
    arrow-down
    1
    ·
    edit-2
    1 year ago

    not undefined in mathematics, an undefined variable is just a variable that hasn’t been defined (yet) and is therefore nonexistent

    • ActuallyRuben@actuallyruben.nl
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Depends on what undefinedwe’re talking about. JavaScript undefined is just a value for undefined variables. In C undefined behavior could be anything, ranging from reading in random garbage to time travel or summoning eldritch terrors.

    • palordrolap@kbin.social
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      There’s deeper subtlety here. There are declared variables, uninitialised variables and variables that will at some point be declared, uninitialised or not, that don’t exist in the logic of the program flow yet. Compilers / interpreters may or may not make distinctions between these, especially if memory is (perhaps only considered to be) in short supply.

      What specific languages do in these cases is wide and varied. Some automatically give all variables a safe, but identifiably undefined value the moment they’re declared, which may or may not be equivalent to the language’s interpretation of null. Or is equivalent in some senses but not others. Looking at you, Javascript.

      In the toilet paper example, the holder might actually still exist but the middle bar might be missing for “identifiably undefined”, and the blank wall is that variable you have literally no idea about.

      Maybe in trying to access it you amaze yourself by finding that you’ve punched through the wall and managed to grab some toilet paper from a neighbouring bathroom cubicle.

      Maybe you instead discover your hand goes through a mincing machine and the pain, oh god why the pain nothing will ever be the same, is that my hard drive churning? No way to tell. Now that’s undefined behaviour.