You are viewing a single thread.
View all comments View context
3 points
*

That is a… strange take.

Random example, imagine a variable that holds the time of the last time the user moved the mouse. Or in a game holding the current selected target of the player. Or the players gold amount. Or its level. Or health. Or current position.

permalink
report
parent
reply
1 point

In all those cases, the answer is to swap in a new variable and throw the old one away.

permalink
report
parent
reply
1 point

Legit question because i think I’m misunderstanding. But if its a const, how are you able to swap or replace it?

permalink
report
parent
reply
5 points

It’s only a const within a function. You can pass the value to another function and changing it as it’s passed. For example:

const int foo = 1
other_func( foo + 1)

In functional programming, you tend to keep track of state on the stack like this.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 3.6K

    Monthly active users

  • 1K

    Posts

  • 38K

    Comments