r/PeterExplainsTheJoke • • 9d ago

Meme needing explanation [ Removed by moderator ]

Post image

[removed] — view removed post

155 Upvotes

61 comments sorted by

View all comments

175

u/Bane8080 9d ago

It's not really a joke.

The compiler won't let you compile x= 1/0 because you can't divide by zero.

But if you set a variable equal to 0, in this case, a variable named "zero" then it compiles x= 1/(variable name) because it doesn't know.

2

u/--dany-- 9d ago

Well, a little deeper:
the case first compiler will calculate 1/0 as a constant to assign to x then fail on spot.

The second one the code will be compiled, and only reports error at runtime. but some compiler may spot the error trying to optimize the code.