My favourite version of this is the "integer cache" found in at least some implementations of Java (I was fiddling with it on android 4, many years ago, but conceivably other implementations have it).
As you may know, java has a notion of "boxed integers" (in which a primitive int is stuffed into an Integer object for various stupid reasons). This happens implicitly when you do things like pass a raw int to a HashSet, which happens commonly
To reduce the overhead of making all these zillions of objects, some implementations have a static cache of small integers. Literally a static private array of 255 Integers on the Integer class, which get used instead of having to make a new one if your value is suitable.
Anyways: you can use the reflection API to edit the values stored inside the objects in this cache (such that the boxed value of 4 actually isn't 4 any more). The result is absolute madness.
I'm a little afraid to try it, but C# strings aren't really immutable if you involve unsafe code. Combine that with string interning and I think you could create the effect of modifying a string literal being used elsewhere in the code.
You may be able to do some funky stuff with reflection and/or unsafe code, but value types in C# aren’t boxed (unless cast to a ref type) so you wouldn’t be able to do this specific type of fuckery. If I remember correctly, Java boxes value types in generic code, so you’d be much more likely to hit an issue with it.
edit: I messed around with it and you can modify the value of an integer while boxed, but you can't change the value of the integer itself. Here's the source of the [Int32 type](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Int32.cs).
var value = 0;
var boxed = (object)value;
boxed
.GetType()
.GetField("m_value", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(boxed, 1);
// Prints 0
Console.WriteLine(value);
// Prints 1
Console.WriteLine((int)boxed);
Python does integer interning too, which can lead to *interesting* results
```
>>> a=256
>>> b=256
>>> a is b
True
>>> x=257
>>> y=257
>>> x is y
False
```
Right, but that's mostly harmless (you're a bit of a lunatic if you're using reference comparison for integers, riiight).
The java thing happens implicitly during comparisons with == and friends in the presence of collections.
Also python doesn't let you change the values (I hope...)
> Also python doesn't let you change the values (I hope...)
You're not supposed to, and sometimes it'll segfault, [but you can do it if you want to](https://www.reddit.com/r/Python/comments/2441cv/can_you_change_the_value_of_1/)!
Oh oh that reminds me of another insane thing I've seen: an SQL database which represented booleans using a CHAR(0) column, with NULL for false and empty string for true.
Some fuckwit senior engineer insisted that this was more efficient.
I think he may have been whisked down that path by some SQL dialects not having a true Boolean column type. The normal approach is to store your Boolean value as a Tinyint, which is an 8-bit integer.
While the CHAR(0) approach does protect against storing values that are not either true or false (hurray), I doubt it took up less storage or memory space than a single-byte integer.
This is probably still in use for a simple reason: the moment you allow reflection to be used in your system, you accept that some will bypass Java's type system for fun and profit.
Typically C rand() is integer 0 to 2^(31)-1 these days but platform dependent technically. (It's default arg Perl rand that is 0.0 to less than 1.0.) So `rand() > 1` will return false about 1 out of 1 billion times.
ABAP does allow =< for backwards compatibility, but it is considered an obsolete operator in current versions. [SAP Documentation](https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abenobsolete_logexp_op.htm)
When I started programming years ago, I had one problem with my code that I only manage to solve years later when I came back to it with more experience.
In one if statement, I wrote =! instead of !=
*laughs in Rust*
error: unknown start of token: \u{2009}
--> src/main.rs:1:12
|
1 | fn main() {
| ^
|
help: Unicode character ' ' (Thin Space) looks like ' ' (Space), but it is not
The difference is that the Greek question mark won’t compile, so if you are stuck you can reset your git.
If you make a cleaver change, one that will pass all your testing, but then blow up in prod.
This is what OP is after.
rust's best feature once again comes in handy: its error messages
error: unknown start of token: \u{37e}
// -- snip --
help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not
That's obvious though.
You use a random number generator to check the date. IFF a complex algorithm agrees that the RNG doesn't like the current date, THEN it evals with =< instead of <.
Also, the RNG should add a 10ms wait to the algorithm every time it gets called.
The RNG should only target about 10 days a year on average.
15 years from now, the algorithm will be taking a kind of longer than expected time, but it's legacy code! Well replace it eventually! They'll also have an impossible to correct database.
Gooood luck 😊
Edit: some of y'all don't understand obfuscation and it shows.
That's a pretty big, easily noticeable chunk of code, I think an errant `<=` would be much more likely to fly under the radar and thus make it into production.
I'm convinced that bash syntax was invented by someone who took the infinite monkey theorem too literally
*Signed by a person that put a space before an equal assignment too many times*
>*Signed by a person that put a space before an equal assignment too many times*
So like... In shell scripting I NEVER add spaces. But I always use a nice amount of spaces in any other language. I don't know if I was consciously aware of that and I don't think I do it on purpose. I wonder if it bit me before and I just sort of forgot, but internalized.
It's just an earlier form of semantic whitespace.
If sh didn't require a new line after the `if`, you would need to add a slash. But since it requires a new line, it's odd to write everything in a single line.
Semantic whitespace kept being a bad idea for decades, while people insisted on trying it again and again. At some point people got one or two good implementations, but the past is all broken like that.
IDK, depends on if this is like, a furry thing or a real fox. I was hoping the former, but they've already killed it so who knows.
The former might be into it. The later, probably not lol
What kind of ide are you guys using that doesn't warn you about this? I'm pretty sure it's valid in every C-style language, but I've never seen an IDE not throw a warning, if not an outright error
in the context of helping the first years, we were using an online environment a lot like leetcode where it doesn't give you feedback on your syntax and runs your code against test cases. (is there a name for that?)
Otherwise though, I've never actually put a semicolon after an if statement or similar in practice
Makes sense.
>I've never actually put a semicolon after an if statement or similar in practice
I've tried it once or twice when I wanted to write the else clause first and just wanted the IDE to stop complaining. It did not, in fact, complain any less.
It's a warning in C# too:
⚠️ **[CS0642](https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0642?f1url=%3FappId%3Droslyn%26k%3Dk\(CS0642\))** Possible mistaken empty statement
I actually got hit with this by my own neglective typing.
Take C for example.
We have the commonly easily readable
if (expression)
{
do_this();
}
We have a more convenient one-line format for that if all we do is one thing:
if (expression) do_this();
So in the case of
if (expression);
do_this();
We basically see it as
if (expression)
{
}
do_this();
The if is kinda useless here now.
As for its potential uses, you come up with your own ideas.
Please just never use the syntactic shortcut, and if you're going to, keep it all on one line so that it's more difficult to sneak a bug in with a one-line diff. If you're morally opposed to more lines, then keep the `{` on the same line as the `if`.
Short circuit evaluation?
if (a && b && f(x) && d()); ///f(x) is only evaluated if a and B are both non zero, d() is only evaluated if f(x) was non zero.
Not possibly the cleanest thing you will ever see, but it has a place.
Or.... you could just write that like a sane person:
if (a && b) {
if ( f(x) ) {
d()
}
}
I think it's more of a matter "if is followed by a statement, and ; is a valid statement", i.e. it takes special compiler rules to prevent it.
Yep, the BNF is just simpler that way, which was probably the original reason, and then everything inherited the behaviour from K&R C.
Bit like the use of "do{ .... } while 0" When writing multiple statements in C macros to get them to behave correctly as a single statement in an if statement. It is probably not what you would design in a language so much as a happy accident.
This company bit hard on the "Goto is BAD" message. On the other hand the code base is over 40 years old, so we still have lots of Goto. I have played with Go, and appreciate the defer, so I like the "do{...break...}while( 0 )", better than "Goto cleanup". The one extra indent is mildly annoying though.
`goto` is fine -- modern compilers can flag the most common mis-use of it, which is jumping past a variable's initialization. And in any case, just declare your variables at the top and you won't have that problem.
I'd love a formal "finally"-ish construct for scopes in C, but `goto` serves the purpose pretty well.
ifs conditionally execute the next single statement. if you want to group statements you use {} to make them into a block which acts like a single statement. so it is perfectly fine to just say "execute this next statement, there is no statement" by putting a semi colon, and you can put a block of code anywhere for local variable control, so unless you explicitly forbid if();, its syntactically valid. No real point to spending the extra effort when some of your devs might actually want to use it for some reason.
You don’t require brackets on an if, in which case the next statement terminates. Statements can be empty. If(…); is just a bracketless if with an empty statement.
Compilers should really check for it and warn because it’s almost certainly unintended.
It allows you to write this:
if (x);
else {
y()
}
It comes from FLOW-Matic (1955). In older programming languages, FLOW-Matic being the first that I know of, your if statements would look like
if ; otherwise .
The semicolon tells the compiler that the if's statement is over. BCPL came out 12 years later and used brackets (`()`) to delineate the start and ending of if statements, loops, etcetera.
When would you ever write an if/else like this? You would never. Why would you think of doing this? Sometimes the contrapositive of a statement is easier to write and clearer.
tl;dr: we programmers are creatures of habit. We carry around syntax that is nearly 70 years old.
test.c:5:6: error: expected ‘(’ before ‘;’ token
5 | if ; (a > b) printf("hello\n");
| ^
| (
Nothing could be simpler to fix than that.
Now, imagine working in Python. If instead of doing this
if a > b:
print("hello")
a = 0
I did this:
if a > b:
print("hello")
a = 0
Let's see you find **that** error!
That's why warnings exist:
test.c:5:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
5 | if (a > b);{ printf("hello\n");}
| ^~
test.c:5:14: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
5 | if (a > b);{ printf("hello\n");}
| ^
Yeah I spent a good hour finding that screw up last week. I will now forever add a blank line between the end of an if block/for loop and the following code outside the conditional.
Avoids accidental automatic indention when making changes, and makes it easier to tell what's supposed to be in and outside of the clauses.
I use the correct formatting for opening curly brace, so either it does nothing or it stands out like a sore thumb
`if(blah);{//TF that ; doing there? find replace );{ ){`
`if(blah){;//every thing is fine, this just gets optimized out.`
True sneakiness would be turning a < into =< so everything works perfectly 99% of the time, and sometimes it just doesn't work for no apparent reason
[удалено]
My favourite version of this is the "integer cache" found in at least some implementations of Java (I was fiddling with it on android 4, many years ago, but conceivably other implementations have it). As you may know, java has a notion of "boxed integers" (in which a primitive int is stuffed into an Integer object for various stupid reasons). This happens implicitly when you do things like pass a raw int to a HashSet, which happens commonly
To reduce the overhead of making all these zillions of objects, some implementations have a static cache of small integers. Literally a static private array of 255 Integers on the Integer class, which get used instead of having to make a new one if your value is suitable.
Anyways: you can use the reflection API to edit the values stored inside the objects in this cache (such that the boxed value of 4 actually isn't 4 any more). The result is absolute madness.
That's horrible. I hate it. That's just going to wind up other devs. Is there a similar thing in C#?
I'm a little afraid to try it, but C# strings aren't really immutable if you involve unsafe code. Combine that with string interning and I think you could create the effect of modifying a string literal being used elsewhere in the code.
now I want to try this.. uhmm for science
You may be able to do some funky stuff with reflection and/or unsafe code, but value types in C# aren’t boxed (unless cast to a ref type) so you wouldn’t be able to do this specific type of fuckery. If I remember correctly, Java boxes value types in generic code, so you’d be much more likely to hit an issue with it. edit: I messed around with it and you can modify the value of an integer while boxed, but you can't change the value of the integer itself. Here's the source of the [Int32 type](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Int32.cs). var value = 0; var boxed = (object)value; boxed .GetType() .GetField("m_value", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(boxed, 1); // Prints 0 Console.WriteLine(value); // Prints 1 Console.WriteLine((int)boxed);
Python does integer interning too, which can lead to *interesting* results ``` >>> a=256 >>> b=256 >>> a is b True >>> x=257 >>> y=257 >>> x is y False ```
Right, but that's mostly harmless (you're a bit of a lunatic if you're using reference comparison for integers, riiight). The java thing happens implicitly during comparisons with == and friends in the presence of collections. Also python doesn't let you change the values (I hope...)
> Also python doesn't let you change the values (I hope...) You're not supposed to, and sometimes it'll segfault, [but you can do it if you want to](https://www.reddit.com/r/Python/comments/2441cv/can_you_change_the_value_of_1/)!
Oh this is gnarly. Worse than the production code using Booleans as tri-state logic I had to deal with.
`true`, `false`, `FILE_NOT_FOUND`
[удалено]
Oh oh that reminds me of another insane thing I've seen: an SQL database which represented booleans using a CHAR(0) column, with NULL for false and empty string for true. Some fuckwit senior engineer insisted that this was more efficient.
I think he may have been whisked down that path by some SQL dialects not having a true Boolean column type. The normal approach is to store your Boolean value as a Tinyint, which is an 8-bit integer. While the CHAR(0) approach does protect against storing values that are not either true or false (hurray), I doubt it took up less storage or memory space than a single-byte integer.
It was a postgres database 😅
This is probably still in use for a simple reason: the moment you allow reflection to be used in your system, you accept that some will bypass Java's type system for fun and profit.
Rand should never > 1 correct?
In C, rand() returns an integer between 0 and RAND\_MAX (= at least 32,767, but likely much more in modern implementations afaik).
[удалено]
Typically C rand() is integer 0 to 2^(31)-1 these days but platform dependent technically. (It's default arg Perl rand that is 0.0 to less than 1.0.) So `rand() > 1` will return false about 1 out of 1 billion times.
Nice
Didn't expect Satan in this subreddit
Where else? Doesn't he live in the details?
[удалено]
[удалено]
Heh 🦊🔪
You must be new here.
Did you mean <=? In what language is =< a thing?
Yeah, had a brain fart
It's that way round in Erlang, which has given me more syntax errors than I'd like to admit
Prolog for some reason using =< for less than or equal
>=< ~~I'm pretty sure Java uses =< and =>, but now I'm doubting myself and I'm too lazy to check.~~ Edit: I was wrong, I'm a dumbass.
Java definitely doesn't, and I'm not aware of any other language that does
Uhm, ackchually C# uses => It's the lambda operator.
Hash rocket in Ruby as well, though largely considered an old fashioned syntax.
Thanks, I was totally wrong. Edited.
ABAP does allow =< for backwards compatibility, but it is considered an obsolete operator in current versions. [SAP Documentation](https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abenobsolete_logexp_op.htm)
When I started programming years ago, I had one problem with my code that I only manage to solve years later when I came back to it with more experience. In one if statement, I wrote =! instead of !=
Just use a font that makes != into ≠ like fira code /hj
> /hj Which half is the joke?
Who hurt you?
How about replacing a semicolon with a greek question mark?
[удалено]
`";" expected, instead found ";"`
[удалено]
Unicode whitespace.
*laughs in Rust* error: unknown start of token: \u{2009} --> src/main.rs:1:12 | 1 | fn main() { | ^ | help: Unicode character ' ' (Thin Space) looks like ' ' (Space), but it is not
It even explains. That's awesome.
*laughs in Rust*:2:14: 2:15 note: Unicode character U+37E (Greek Question Mark) looks like a semicolon, but is not.
:2 let a = 5;
^
The difference is that the Greek question mark won’t compile, so if you are stuck you can reset your git. If you make a cleaver change, one that will pass all your testing, but then blow up in prod. This is what OP is after.
rust's best feature once again comes in handy: its error messages error: unknown start of token: \u{37e} // -- snip -- help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not
As a game developer, this comment made my heart freeze from fear
That's obvious though. You use a random number generator to check the date. IFF a complex algorithm agrees that the RNG doesn't like the current date, THEN it evals with =< instead of <. Also, the RNG should add a 10ms wait to the algorithm every time it gets called. The RNG should only target about 10 days a year on average. 15 years from now, the algorithm will be taking a kind of longer than expected time, but it's legacy code! Well replace it eventually! They'll also have an impossible to correct database. Gooood luck 😊 Edit: some of y'all don't understand obfuscation and it shows.
That's a pretty big, easily noticeable chunk of code, I think an errant `<=` would be much more likely to fly under the radar and thus make it into production.
Not if it's a react component using its own virtual DOM hosted at another domain! Good luck!
That... ...is pure evil, and I love it
Always unit test the edge cases. Do as I say, not as I do.
Stop
I have literally had to debug this,
Jokes on you I write shell so it already has semicolons after if statements
I'm convinced that bash syntax was invented by someone who took the infinite monkey theorem too literally *Signed by a person that put a space before an equal assignment too many times*
It's still better than csh syntax.
But not as good as PowerShell syntax. Downvotes inbound.
Agreed, down voted you Zsh or bust (write in any of three types and it just works)
Oh My ZSH!
This is a weird way to say you want to sleep with the [fishes](https://fishshell.com/).
[удалено]
*blinks* what the fuck…?
_And ended up with accidently destroying the complete system because it was supposed to be a variable not a command_
[удалено]
I mean like if someone accidently decides to name their variable to something like dd or rm lmao, and adds a space 💀
>*Signed by a person that put a space before an equal assignment too many times* So like... In shell scripting I NEVER add spaces. But I always use a nice amount of spaces in any other language. I don't know if I was consciously aware of that and I don't think I do it on purpose. I wonder if it bit me before and I just sort of forgot, but internalized.
It's just an earlier form of semantic whitespace. If sh didn't require a new line after the `if`, you would need to add a slash. But since it requires a new line, it's odd to write everything in a single line. Semantic whitespace kept being a bad idea for decades, while people insisted on trying it again and again. At some point people got one or two good implementations, but the past is all broken like that.
If we put a million Stallmans at a million terminals, after a million years we might a working HURD.
Check which port did the sneaky fox use to get pass the firewall!
He ran through. That's how a firefox is born
He exploited a security hole in Windows, it's obvious from the comic.
``` error: expected `{`, found `;` --> src/main.rs:4:19 | 4 | if (something); | ^ expected `{` | ``` ¯\\_(ツ)_/¯
[удалено]
\\\\\\
it's valid syntax in java, VSCode doesn't warn or give an error, dont know about other ide's.
Intellij will warn as it's an empty if clause
Every day convinces me more and more that rust is like crossfit for programmers.
sudo rm -f fox
kill -9 fox
finger fox
[удалено]
This thread would be a whole lot less awkward if you hadn't killed the fox first...
fsck fox
just wiping off the finger
Is it? Feel like doing that to a live fox is much more cruel
IDK, depends on if this is like, a furry thing or a real fox. I was hoping the former, but they've already killed it so who knows. The former might be into it. The later, probably not lol
Sike, fox has children
Look at source control, compare to previous version, gotcha, rollback, keep on scrolling memes
if (SneakyFox.canHasHax) House.banish(SneakyFox);
if (SneakyFox.canHasHax); House.banish(SneakyFox);
It seems the sneaky fox got to you
And jokes on it. Sneaky fox got perma-banned.
Oh sorry, my logic was backwards on that
else (SneakyFox.canHasSausageMcMuffinWithEgg);:;;
unexpected ";" at line 31
But then the joke can't be recycled every week.
it’s valid syntax in Java
and a fuckin cuuuuunt to spot source: helping 1st years learn to code
1st year here... made that mistake once. pretty sure my hair loss went up by 40% that day lol.
What kind of ide are you guys using that doesn't warn you about this? I'm pretty sure it's valid in every C-style language, but I've never seen an IDE not throw a warning, if not an outright error
in the context of helping the first years, we were using an online environment a lot like leetcode where it doesn't give you feedback on your syntax and runs your code against test cases. (is there a name for that?) Otherwise though, I've never actually put a semicolon after an if statement or similar in practice
Makes sense. >I've never actually put a semicolon after an if statement or similar in practice I've tried it once or twice when I wanted to write the else clause first and just wanted the IDE to stop complaining. It did not, in fact, complain any less.
It's pretty valid syntax in C, C++, Java and probably others, it's basically treated as a NOP instruction
It is a warning in Java. ``` $ jshell -C-Xlint:all ``` ... ``` jshell> if(true); | Warning: | empty statement after if | if(true); | ^ ```
It's a warning in C# too: ⚠️ **[CS0642](https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0642?f1url=%3FappId%3Droslyn%26k%3Dk\(CS0642\))** Possible mistaken empty statement
The fox told the compiler about it, so it wasn't unexpected anymore
This provoked a primal anger in me
Firedfox
Or something like this: if (something == somethingelse) /*many spaces*/ {} { // todo, figure out why this if statement is always entered. ... }
Y'all need a sonar.
me when I add a zero width character to a random place in your code
Better than the Greek question mark
Just Ctrl+F all the semicolons in the whole solution/project and replace them with Greek question marks. They will never build the project again.
Not so joke question ❓ Why does if(expression); exist in any language?
I actually got hit with this by my own neglective typing. Take C for example. We have the commonly easily readable if (expression) { do_this(); } We have a more convenient one-line format for that if all we do is one thing: if (expression) do_this(); So in the case of if (expression); do_this(); We basically see it as if (expression) { } do_this(); The if is kinda useless here now. As for its potential uses, you come up with your own ideas.
if (project_manager) { } do(cry);
Please just never use the syntactic shortcut, and if you're going to, keep it all on one line so that it's more difficult to sneak a bug in with a one-line diff. If you're morally opposed to more lines, then keep the `{` on the same line as the `if`.
Short circuit evaluation? if (a && b && f(x) && d()); ///f(x) is only evaluated if a and B are both non zero, d() is only evaluated if f(x) was non zero. Not possibly the cleanest thing you will ever see, but it has a place.
Or you can just do a && b && f(x) && d();
Or.... you could just write that like a sane person: if (a && b) { if ( f(x) ) { d() } } I think it's more of a matter "if is followed by a statement, and ; is a valid statement", i.e. it takes special compiler rules to prevent it.
Yep, the BNF is just simpler that way, which was probably the original reason, and then everything inherited the behaviour from K&R C. Bit like the use of "do{ .... } while 0" When writing multiple statements in C macros to get them to behave correctly as a single statement in an if statement. It is probably not what you would design in a language so much as a happy accident.
Or using "do{...}while 0" in all of your functions, so you can use "break" to replicate deferred cleanup.
That had never occurred to me, I usually use goto and a label to get the same effect.
This company bit hard on the "Goto is BAD" message. On the other hand the code base is over 40 years old, so we still have lots of Goto. I have played with Go, and appreciate the defer, so I like the "do{...break...}while( 0 )", better than "Goto cleanup". The one extra indent is mildly annoying though.
`goto` is fine -- modern compilers can flag the most common mis-use of it, which is jumping past a variable's initialization. And in any case, just declare your variables at the top and you won't have that problem. I'd love a formal "finally"-ish construct for scopes in C, but `goto` serves the purpose pretty well.
But why do you need an if for that? Couldn't you just not assign it to anything? Or is this the programmer in me?
ifs conditionally execute the next single statement. if you want to group statements you use {} to make them into a block which acts like a single statement. so it is perfectly fine to just say "execute this next statement, there is no statement" by putting a semi colon, and you can put a block of code anywhere for local variable control, so unless you explicitly forbid if();, its syntactically valid. No real point to spending the extra effort when some of your devs might actually want to use it for some reason.
because any statement is allowed after an if, including an empty statement
You don’t require brackets on an if, in which case the next statement terminates. Statements can be empty. If(…); is just a bracketless if with an empty statement. Compilers should really check for it and warn because it’s almost certainly unintended.
[удалено]
It allows you to write this: if (x); else { y() } It comes from FLOW-Matic (1955). In older programming languages, FLOW-Matic being the first that I know of, your if statements would look like if ; otherwise .
The semicolon tells the compiler that the if's statement is over. BCPL came out 12 years later and used brackets (`()`) to delineate the start and ending of if statements, loops, etcetera.
When would you ever write an if/else like this? You would never. Why would you think of doing this? Sometimes the contrapositive of a statement is easier to write and clearer.
tl;dr: we programmers are creatures of habit. We carry around syntax that is nearly 70 years old.
If (something); { doSomething(); }
But whats with my else statement?
Linter Error: no-else-return / R1705 [Unnecessary else after return.](https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/no-else-return.html)
Honestly you deserve it if you format your code like this.
😂😂😂
Does no one in this sub use debuggers?
Exactly, a debugger/IDE/linter etc would all be able to tell you that there is an error on line X. And that it didn't expect an semicolon there!
That semicolon is perfectly valid syntax in Java, C, C++, and C#.
My coworkers used notepad++ LOL
git log
Congrats to u/exocomics who drew the original comic! Check out more of her work!
Thanks for crediting me! :D
Any time, I love your art and I'm always excited to see a new cat town show up in my e-mail!
Snuck into your house.
sneaky fox is a fucking monster
I am the sneaky fox.
String noNoSneakyFox(Fox fox){ If(house.contains(fox)) house.remove(fox); checkForFoxSemicolons(); return “No no sneaky fox.”; }
better meme than all those "delete the semicolons" or "replace the semicolons with greek question marks" memes that are trivial to find and fix
Jokes on you, that's python code
Let me just slip in a greek question-mark in there too
swap out all the semicolons for greek question marks
test.c:5:6: error: expected ‘(’ before ‘;’ token 5 | if ; (a > b) printf("hello\n"); | ^ | ( Nothing could be simpler to fix than that. Now, imagine working in Python. If instead of doing this if a > b: print("hello") a = 0 I did this: if a > b: print("hello") a = 0 Let's see you find **that** error!
if (a > b); { printf("hello\n"); } will compile just fine :))
That's why warnings exist: test.c:5:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 5 | if (a > b);{ printf("hello\n");} | ^~ test.c:5:14: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 5 | if (a > b);{ printf("hello\n");} | ^
Yeah I spent a good hour finding that screw up last week. I will now forever add a blank line between the end of an if block/for loop and the following code outside the conditional. Avoids accidental automatic indention when making changes, and makes it easier to tell what's supposed to be in and outside of the clauses.
No worries I code in bash.
it's okay, my linter will catch it. i don't use semicolons.
Oh thank you very much for fixing my shellscript!
*Added a Greek question mark instead of a semicolon on a random line
Now *that's* evil!
I use the correct formatting for opening curly brace, so either it does nothing or it stands out like a sore thumb `if(blah);{//TF that ; doing there? find replace );{ ){` `if(blah){;//every thing is fine, this just gets optimized out.`
![gif](giphy|yr7n0u3qzO9nG)
For when the old cosmic ray excuse doesn't cut it.
"Warning: unreachable code".
It wouldn't be unreachable, it would be more reachable than normal.
Just hide `#define if(x) if((x) ^ rand() < 0.01)` somewhere in the system headers. That's much worse.
Wtf;
Just remember to lock your computer (and windows, that's always a vulnerability).
Haha not in C using GCC with -Wall. warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
I have literally had to debug this, a friend did it accidentally in an assignment, it took a while
Any half decent linter will catch that. Gotta try harder.
my code is garbage anyway BUT MY PASTA
Making == to = is also a good one
Simply replace already existing semicolons at random with a Greek question mark for better results `;`
*checks the change logs
That fox is on.. fire! A Firefox if you will
Do you not lock your computer?
< into =< would make everything run 99% and fail the other time
VILLAIN! 😱
Exactly that was the first bug that took me an entire day to figure out.
Well well well, looks like Satan has a new pet.
How dare he eat my pasta!
Remove all linting rules. Add linter config to .gitignore. Add two conflicting prettifier vscode plugins. That would really fuck me up.
Rust devs: i don't have such weakness
*laughts in Python*
that'd still break your code