For(;;)

for(;;)
or
While(true)

Which one should you use?

Other urls found in this thread:

godbolt.org/g/4yxfYG
kukuruku.co/post/undefined-behavior-and-fermats-last-theorem/
youtu.be/yG1OZ69H_-o
twitter.com/AnonBabble

Whichever one you like, OP.

for(let i = 0; i < Infinity; i++) {
}

while (true)

both are deprecated. use loop

do{}while(true)

>blocks your path
for { }

for (;;) spiderface

i use
for(; true;)

Begin:
Goto Begin;

Only using goto in all my code has made me invaluable in my workplace

iterate(f)

#define ever (;;)
int main(){
for ever{
//do stuff
}
return 0;
}

you should use map and foldl

foreach in javascript and C#

IN RUBY:
array.each do |element|
element.do_stuff
end

#define loop(shit) while(true){shit}
loop(
std::cout

???

until false

for(;true;)

while :; do fortune | cowsay ; done

yes hello world

Both
for (boolean i = true; i; !i) {
while(!i){
i = !i;
}
}

Sorry I'm retarded. I meant:

for (boolean i = true; i; i = !i) {
while(i){
i = !i;
}
}

This may seem regular shitpost but it's actually interesting. Down to the assembly level, does using while(true) involves checking the true condition everytime? Using a goto would be better at this point. But I'm pretty sure any decent compiler has this covered.

start:
...
goto start;

>checking the true condition everytime
Of course not, stupid. That doesn't even happen with optimization turned off.

while true is the most readable

down to assembly level the compiler is not that dumb and will just produce an unconditional jump. I just tried it on GCC and both produce exact same code.
Unless you compile with no optimizations, that is, but that would be your fault, then.

What people tend to forget that at the level compilers are these days, C or C++ code is likely to be compiled into instruction sequences you never imagined it would.

I only know JavaScript c# and ruby.

literally no difference since the gcc translates it both to the same thing

who gives a fuck, they're do the same thing, fo(;;) is less characters though so that would be the choice.

godbolt.org/g/4yxfYG

use do{}while(false) to contain every single statement you write. It's the only way.

Fuck, this triggers long-dormant PTSD from my first year of college

while (false)

while (true != false)

while (1==-e^(i*pi))

...

Be careful with that.
kukuruku.co/post/undefined-behavior-and-fermats-last-theorem/

This may seem silly but it's very useful in practice. When you're not making mistakes.

read the OP retard

It gets compiled to the same machine code. Doesn't matter.

void loop (void)
{
doStuff();

loop();
}


*absolutely blocks your path

template
void loop (F fun)
{
fun();
loop(fun);
}

This
t. Uncle Bob

Neither.

rust is a meme

I never understood why the C standard permits compilers to do whatever they want when they encounter undefined behavior. Why not just crash the program?

You can ask compilers to trap (crash) in a lot of these situations, I don't do it so I'm not sure how well they do. Not specified by the standard though. And there's tools to help you now. Wasn't the case just 5 years ago.
But basically if you allow parts of the program to be unspecified you offer the compiler more room to move. If you defined every operation very strictly or in a manner that's too high level to reason about (the as-if rule only helps if your compiler is good enough) your program will be very slow.
If you're really interested here's someone arguing about it at Cppcon.
youtu.be/yG1OZ69H_-o
I agree with him in the context of C/C++ but as you'll even see him suggest if you look at it there's way better solutions to these problems than leaving traps for programmers to stumble upon, as it is now. And they're not gonna do 'whatever', he leads with that. They're only doing what helps the program. The example of fermat's theorem is dead code elimination. It's perfectly valid in other circumstances.
The historical reason is always that UB is a means of supporting multiple platforms effectively. You define what's largely platform agnostic. Leave the specifics as UB. Ints aren't twos complement for instance, very historical that one.

Bjarne called. He wants his stack back.

#define loop while(true)
loop {
std::cout

>not even "what did he meme by this"

>while (true)
>not while (1)
dumbos

>casting int to bool
>to make it less readable
Wow.

>what is tail call optimization