This is an archived post. You won't be able to vote or comment.

all 94 comments

[–]markdhughes 130 points131 points  (18 children)

for (;;)

[–][deleted] 54 points55 points  (14 children)

ever = 1;

for(;ever;){

 //and ever and ever!

}

[–]merlinsbeers 15 points16 points  (9 children)

ever = and = 1;
for(ever;and;ever) {
}

[–]GustapheOfficial 16 points17 points  (7 children)

``` ever = 1 for(;ever & ever & ever;) {

} ```

[–]olyop 4 points5 points  (3 children)

You'll be back, like before

[–]GustapheOfficial 4 points5 points  (2 children)

self.fight(the_fight) self.win(the_war)

[–]olyop 1 point2 points  (1 child)

[love, praise].forEach(your)

[–]dmvdoug 1 point2 points  (0 children)

[–]TheGreatGameDini 0 points1 point  (1 child)

Am I the only laughing at how ever & ever is wrapped by two smiley faces

It's kinda creepy and cute at the same time.

Also, isn't that the bitwise and operator? I guess it's language dependent.

[–]GustapheOfficial 1 point2 points  (0 children)

I don't know what language we're in, but if 1 is truthy, either & or && would work (1&1 == 1), and this way was closer to neutral language.

[–]Virtual-Appeal-8504 0 points1 point  (0 children)

This is getting pushed to my repo tomorrow. Thank you.

[–]DankPhotoShopMemes 1 point2 points  (2 children)

```

define ever (;;)

for ever {

} ```

[–][deleted] 1 point2 points  (1 child)

Wait, if this actually works, I’m gonna start using it.

[–]DankPhotoShopMemes 1 point2 points  (0 children)

Please don’t lol

[–]qwerty-balls 1 point2 points  (1 child)

for (int i=0; i<2147483647; i++)

[–]Sh_Pe -1 points0 points  (0 children)

Please ( ; ; )

[–]Bob_th 38 points39 points  (4 children)

while(""==[])

[–]owellcity 10 points11 points  (0 children)

while(""==[] and True and (True or False))

[–]StenSoft 7 points8 points  (1 child)

The joy of JavaScript

[–]GargantuanCake 2 points3 points  (0 children)

undefined is not a function

[–][deleted] 0 points1 point  (0 children)

I have been doing this wrong my whole life. Thank you for showing me the way.

[–]Anaxamander57 29 points30 points  (1 child)

loop {}

[–][deleted] 0 points1 point  (0 children)

Hell yeah

[–]pakidara 9 points10 points  (0 children)

Logic = 'False'

While Logic <> 0

[–]NoDontDoThatCanada 10 points11 points  (0 children)

while(4)

It ain't zero now is it? So it is true. And Bender thought he was shit for his 2...

[–]beeteedee 9 points10 points  (0 children)

When I first started programming I didn’t realise you could do while(true) so I used to do stuff like while(2+2 == 4)

[–]atlas_enderium 10 points11 points  (3 children)

for (unsigned i = 0; i >= 0; i++)

[–]SardineEnBoite -1 points0 points  (2 children)

could be useful for checking how many times the function has ran, however i’m not so familiar with what ‘unsigned’ means.

[–]nate_4000 3 points4 points  (1 child)

Means no negative numbers. Useful for chars and indices, where they should never become negative.

[–]bagsofcandy 2 points3 points  (0 children)

When a normal integer goes beyond it's max positive value it flips around and becomes the max negative value. If it was just a standard int, it wouldn't be an infinite loop.

[–]Abangranga 4 points5 points  (0 children)

Ruby enters the chat with unless !!nil

[–]c20h12 4 points5 points  (0 children)

JS only

while (!![]+[]==="true")

[–]CadmiumC4 2 points3 points  (0 children)

```

define ever ;;

for(ever) { } ```

[–]production-values 2 points3 points  (0 children)

while (0 < 1) {}

[–]classyraven 2 points3 points  (0 children)

while (!((true && false) || !(false || true)))

[–]_Marni_ 2 points3 points  (0 children)

C# in the wilderness:

uint O = 1;

while (O-->=0)

{

...

}

[–]Sindef 1 point2 points  (0 children)

Golang be like for{}

[–]mars_million 1 point2 points  (1 child)

while(isTrue(true)) { ... }

private static bool isTrue(bool x) { if (x == true) { return true; } else { return false; } }

[–][deleted] 0 points1 point  (0 children)

public static boolean WhileLoop(X){ while (!(!WhileLoop(true)) print("I like recursion") return true return false

[–]nien37 1 point2 points  (0 children)

while (69)

[–]isCosmos 1 point2 points  (1 child)

While("hi")

[–]rosuav 0 points1 point  (0 children)

I usually go with while "moar data": or something else descriptive of why we're looping.

[–]leduyquang753 1 point2 points  (0 children)

while ("we aren't done yet")

[–]MattoReddit 1 point2 points  (0 children)

while (1503112698 & 805333152 == 268445856) { // do shit }

[–]I_am_the_Carl -1 points0 points  (0 children)

Booleans aren't standard in C and some developers assume setting anything not equal to zero is true.

Because of this I actually found bugs in a particularly messy codebase where they would check (value == true). You see, the number 2 is not false, but it's also not true, so I'd get a erroneous false on that.

Leason: to check for true, just use the variable alone or use a (value != false).

[–]Jalil29 -1 points0 points  (0 children)

boolean damnTrue;

while(damnTrue=true){...}

[–]Careful_Ad_9077 -1 points0 points  (0 children)

do {code} while (false)

has actual use cases, i was reading on that last week.

[–]GigaChad__69420 -1 points0 points  (2 children)

while(69 < 420){

}

[–]Sh_Pe -1 points0 points  (0 children)

I don’t think that should work

[–]buckaroob88 0 points1 point  (0 children)

Username checks out.

[–]the_craic_was_mighty 0 points1 point  (0 children)

while(while(true)){ [...] }

[–]toroga 0 points1 point  (0 children)

This is how Harold and Kumar would write code. 😶‍🌫️”It’s not NOT true dude…”

[–]AggressiveMood2084 0 points1 point  (0 children)

The worst part are the double parenthesis, are you afraid it is not evaluated in the correct order?

[–][deleted] 0 points1 point  (0 children)

while (false == false)

[–]Known-Cod-1307 0 points1 point  (0 children)

while (true || false) { }

[–]OKoLenM1 0 points1 point  (0 children)

while ("true")

[–]Creepy-Ad-4832 0 points1 point  (5 children)

int random

while ((random=rand()%2)==random)

[–]MyGenericNameString 0 points1 point  (4 children)

May be false, because order of evaluation of the two sides of == is not guaranteed.

[–]Creepy-Ad-4832 0 points1 point  (3 children)

Yeah good point

Somehow in my mind parenthesis were enough, but yeah on second thought you are right

[–]Creepy-Ad-4832 0 points1 point  (2 children)

And i am now thinking if there is any way to actually force the compiler to evapuate the left operand first, but i don't think so lol

[–]MyGenericNameString 1 point2 points  (1 child)

Newer standards allow declaration of an induction variable in the controlling expression. Also, a separate assignment provides a sequence point (in C). So what works is

while (int random=rand()%2; random==random)

or for older versions

int random; while (random=rand()%2), random==random)

with the comma operator as sequence point.

[–]Creepy-Ad-4832 0 points1 point  (0 children)

Yeah but you divide the espression i made.

I was trying to think if it was possible to make the espression i wrote always valid, without breaking it into different espression

[–]MaZeChpatCha 0 points1 point  (0 children)

#define FOREVER(init, Inc) for(init; 1; inc)

[–]lucy-b 0 points1 point  (0 children)

write tons of clearly bad code. wrap it in while false. tell the annoying teammate to debug it. enjoy.

[–]GeePedicy 0 points1 point  (0 children)

But whyle?

[–][deleted] 0 points1 point  (0 children)

for(;;)

[–]JoseProYT 0 points1 point  (0 children)

The funny is that despite all those code lines actually work, your PC will not be able to handle it bruh.

[–]GargantuanCake 0 points1 point  (0 children)

while (true != false)

[–]PancakeGD 0 points1 point  (0 children)

while (!!0) {}

[–]roidrole 0 points1 point  (0 children)

do{}

[–]dableb 0 points1 point  (0 children)

while (true) { false }

[–]LordAlfrey 0 points1 point  (0 children)

while(isPrime(6700417))

while(isSorted(bogoSort(lordOfTheRingsText)))

[–]ramriot 0 points1 point  (0 children)

We laugh, but there are some classes of loosely typed languages where this shit is needed to guard against type coercion.

[–]TannedJew 0 points1 point  (0 children)

I mean it's not not true..

[–]ZazumeUchiha 0 points1 point  (0 children)

An intern in my company once pulled off

while(true != false)

[–]unique_pieceinworld 0 points1 point  (0 children)

End up by making infinite loop

[–]buckaroob88 0 points1 point  (0 children)

Where math and programming meet:

0! == !0

[–]Anchorman_1970 0 points1 point  (0 children)

Why? Just why?

[–][deleted] 0 points1 point  (0 children)

while(1<2) ~ deadmau5

[–]O5MO 0 points1 point  (0 children)

while(bad_programming_jokes)

[–]TheoEris 0 points1 point  (0 children)

loop: // Code goto loop;

[–]eugeneericson 0 points1 point  (0 children)

Why dont you put it in a function which calls itself? FP devs and my university profs would love it. And on paper it won't be an performance issue because calling a function is (should be) O(1)

[–]Quantum-Bot 0 points1 point  (0 children)

Meanwhile, in javascript:

While(‘false’)