1411
Golang be like (i.imgur.com)
you are viewing a single comment's thread
view the rest of the comments
[-] AeonFelis@lemmy.world 11 points 1 year ago* (last edited 1 year ago)

Yes, worse, because now if you want to use the underscore assignment to indicate that you really want to discard that variable - it gets confused with underscore assignments that were put there "temporarily" for experimentation purpose.

[-] merc@sh.itjust.works 9 points 1 year ago

Exactly.

Say I'm having some issue with a function. I comment out half the function to see if that's where the weirdness is. Golang says "unused variable, I refuse to compile this dogshit!" I completely fool Golang by just using _ = foo. Yes, I was correct, that's where the problem was. I rewrite that section of the code, and test it out, things work perfectly. Only now, it turns out I'm not using foo anymore, and Golang has no idea because I so cleverly fooled it with _ = foo.

Now, something that could be caught by a linter and expressed as a warning is missed by the language police entirely, and may make it into production code.

Police the code that people put into a repository / share with others. Don't police the code that people just want to test on their own.

this post was submitted on 14 Aug 2023
1411 points (98.2% liked)

Programmer Humor

19187 readers
1137 users here now

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

founded 1 year ago
MODERATORS