if ( isTrue() ){ goDo(something);}//vs if ( isTrue() ){ goDo(something);}//vsif ( isTrue() ) goDo(something);
Clearly the first one is superior because your worth is judged by the number of lines of code you wright and it results in an extra line, the last one is just pants on head retarded.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see gnu.org/licenses/>.if ( isTrue() ){ goDo(something);}
smh tbh fam
Owen Johnson
Something about function pointers or a jump table but I'm far too lazy to actually do it.
Blake Mitchell
Switch ( isTrue() ){ case true: goDo(something); break; case false: break; default: break;}
Levi Bell
Second is better for general work because you aren't wasting an extra line. You don't have to scroll as much, and you can see more code on one page. Third is for quick stuff, especially if you aren't held to a code standard. if you're using Perl you can go even further with goDo(something) if isTrue();
And for meme-tier here's a dispatch table my %dispatch;$dispatch{true} = \&goDo;$dispatch{false} = "no";$dispatch{isTrue()}->(something);
Hunter Sanchez
goDo(something); fixed your dead code t. gcc
Thomas Allen
Anyone care to rig up a test harness and tell us which version is slowest?
Logan Hall
laughingsegfaults.jpg
Do you want error prone code? Because that's how you get error prone code. The guys who made the language are not gods. They chose to use in band signalling for string length, for fucks sake.
Real men use this: if Is_True then Go_Do (Something);end if;
Daniel Nelson
Fuck you. BRB inserting null characters in a password field.
Connor Reyes
Never write a single-line if without brackets, lest you want another goto fail fail. It will also consume you more time if you want to expand said if later on, whereas by writing it from the start you can let your editor autocomplete the brackets aulutomatically.
Segfaults are actually good. It's a sign your OS is actually working as intended. Problem is when your program DOESN'T segfault, then you are all sorts of fucked.
C still not having a native string "long long int + char array" struct because "muh overhead not everybody may use" in the era of GB-sized memory is retarded, though. We could have prevented so many fuckups this way it's not even fun. Not deprecating strcpy is even worse; these people just don't fucking learn.
Isaac Richardson
I feel compelled to write some ANSI C code that use strcpy now. At least then it will work on 80's machine (the only ones worth caring about).
Lucas Butler
Couldn't one simply use struct string { size_t length; char *content;} And wrap that up in a typedef and some constructor and accessor functions? Or is there more to strings than that?
I have no idea if I nailed the syntax, function pointer syntax in C is one thing I can never remember correctly and there is no way I'm actually going to compile this abomination
Charles Perry
Close, and yeah, function pointer syntax is weird. typedef return_type (*typedef_name)(argument_list); In this case it'd be typedef void (*action)(int);
Zachary Miller
The first is fucking retarded, the second is ok for most cases, and the third is ok for a short piece of code.
Hunter Gray
1 is the best, its just a standard of orderliness that pretty much every coder agrees to use for the sake of the coders that come after.
however, if your if statement is just a single line of code, then 3 is good, 1 is more for when your IF leads to a chunk of code that is 2+ lines long.
2 is batshit retarded, holy shit i want to kill anyone who uses it.
Jaxson Cook
if (!isGNU()) { interjectFor(aMoment); }
Brody Diaz
:^) while(isTrue()==true){goDo(something);break;}
Jack Jenkins
You could; you'd need to write wrappers for all of the clib string functions as well. It's probably more trouble than it's worth though; if there are code hotspots where e.g. scanning forward to find the end of a string is a bottleneck, you'd be better off hand-optimizing.
Sebastian Hill
Have fun with those buffer overflows, pal
Dominic Rodriguez
Honestly? Yes, it's as simple as that. There are two main problems to that thing, though. First, implementing this in your code is extra work many programmers don't want to do because char arrays are "good enough" (they aren't) and will proceed to fuck up every time, so it would have to be included into the standard, but here comes the second problem: C is designed to include only "what every C programmer may need", but the "C masters" who are in charge of defining new versions of the standard have some very inconsistent guidelines. For example, according to them, every C programmer will use complex numbers (complex.h) in their programs, but of course they won't use sane strings. The C community would probably reject this absolutely crazy idea because 64 bits waste a lot of resources that could very well just be 8 bits or 1 null byte, nevermind this would maybe waste resources but save us several millions in security failures.
Level up your portable assembly and use C++ for christ's sake.
Ethan Mitchell
So you want the standard to hand hold? Why not try another language.
Ethan Williams
Wee
Ayden Barnes
Get the fuck off java pajeets and bsdtards.
End your life faggot
Matthew Campbell
...
Liam Jackson
Bump for requesting someone to test these and let us know which one is slowest.
Matthew Cruz
it's the one that sends the most bytes in the compiler's parser obviously. so that would 1 and 2 by ex-aequo. But more precisely it would have to be 1, because it adds one more optional newline, a specially handled character in the C preprocessor.
Hudson Jones
THIS TBH
Cameron Murphy
Where did this shit meme come from? The official Java code guidelines don't use Allman, but K&R. Although my Java book does come with Allman so you might have a point
Jaxson Richardson
doIfTrue();
Luis Collins
I bet you have the nerve to call others Pajeets in this very board.