@stebo02@sopuli.xyz
link
fedilink
23
edit-2
1Y

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

palordrolap
link
fedilink
31Y

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.

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.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 64 users / day
  • 250 users / week
  • 420 users / month
  • 2.88K users / 6 months
  • 1 subscriber
  • 1.53K Posts
  • 33.9K Comments
  • Modlog