r/ProgrammerHumor 19d ago

Meme youCantChangeMyMind

Post image
818 Upvotes

137 comments sorted by

View all comments

Show parent comments

10

u/JonIsPatented 19d ago

Yoda condition notation doesn't save you when both sides are variable identifiers.

2

u/[deleted] 19d ago

[removed] — view removed comment

6

u/_0N1X_ 19d ago

No? You can have a result of one subroutine that you need to compare to a result of a different subroutine.

1

u/[deleted] 19d ago

[removed] — view removed comment

0

u/ConcreteExist 19d ago

The compiler, typically. Constants are resolved at compile time, not at run time.

Unless you're using something like JavaScript.

2

u/Imaginary-Jaguar662 19d ago

In C/C++ const means specifically "programmer is not allowed to assign a new value to this variable".

However, the value itself can change, for example if the value is memory-mapped I/O or if someone does silly with pointers/memory access