[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>while(true)

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

>>
i got shouted at once for using
while (!!!!!!value && (c = func(..)))
>>
File: 1467986423374.jpg (24KB, 246x216px) Image search: [Google]
1467986423374.jpg
24KB, 246x216px
>while(1 == 1)
>>
>>60964415
while(true):
print("OP is a faggot")
>>
>>60964415
>#DEFINE true = false
>>
while(true){
...
if(cond){
break}
}
>>
>>60964415
break;
>>
>>60964415
>while(1) is a syntax error
>>
for (;;) {}
>>
continue;
>>
File: 1419771764727.jpg (167KB, 673x486px) Image search: [Google]
1419771764727.jpg
167KB, 673x486px
>>60964415
>goto
>>
>>60964643
The white man's infinite loop.
>>
>>60964415


volatile bool a = true;
while(a){


}
>>

while (true) {
...
if (true) {
break;
}
}

>>
do{

}while(cond("true"));

private boolean cond(String cond){
boolean cnd = false;
if(cond.trim().toUpperCase().equalsIgnoreCase("true"){
cnd= true;
}
if(cond.trim().toUpperCase().equalsIgnoreCase("false"){
cnd= false;
}
return cnd;
}
}
>>
>>60964415
>for(;;)
>>
while(System.getProperty("java.version").startsWith("1")) {}
>>
return nigger;
while(false) {
printf("Nigger");
}
>>
>>60964415
#define ever (;;;)
for ever { ... }
>>
>>60964415
label1:
{ }
goto label1
>>
>jnle label1
>>
if (result==true) {
return true;
} else {
return false;
}
>>
>>60965864
>goto
this triggers the autist
>>
endtime = currentTime() + 10sec
do {
// A whole bunch of shit
} while (currentTime() != endtime)

For some reason that loop got regularly stuck in forever mode...
>>
>>60966212
Is there a way to do this for real so that the condition is checked every expression instead of every loop? Without appending a macro to each expression. I'd love something like that for threads instead of just checking at arbitrary points if the flow should break or not.
>>
>while(String.valueOf((new Boolean(true)).equals(Boolean.valueOf(Boolean.TRUE))) != "false")
>>
>>60966212
wtf do you mean "for some reason"
>>
>>60966340
You want it to break the instant the condition is true? It's a very bad idea for most programs, but assuming you know that, I'd implement a listener that runs concurrently.
>>
>>60964415
void f(){
...
f();
}
f();
>>
>>60966399
Sarcasm, my auti friend.
>>
>>60966410
>It's a very bad idea for most programs
There was a specific time that I was working on an embedded device and the client wanted execution to stop IMMEDIATELY when a physical button was released, originally I had arbitrary stages that it would do then check the condition but the client wasn't pleased with this. What I ended up doing was writing a macro and appending it to every expression because I couldn't think of any other way to have it actually exit as soon as possible. They never complained about the finished product and it's been months now. I didn't like the solution I came up with but it worked, I've been curious if there was a better way since though.
>>
>>60964507
>=
kys

>>60964415
I will use recursion next time then!
>>
>>60966488
>What I ended up doing was writing a macro and appending it to every expression
Wew.

The way I implemented something similar with a larger scale robot was by using concurrency. I forgot how I implemented the listener and I'd have to dig through some years old code to figure out exactly how I did it, but it'd just outright stop the thread midway. I'm sure if I cared enough to google "interrupt listener" I'd get some SO results.
>>
>>60966488
With embedded devices I'd say you should be able to use hardware interrupts for that. That's the fastest and cleanest way of doing it.
>>
>>60966577
>>60966612
I'll look into it. I've never had to do something like that before. I don't think the platform supported threads either, there might have been some way to do coroutines. I remember that being an issue.
>>
File: ClZK6JuUYAEt4M7.jpg (43KB, 500x500px) Image search: [Google]
ClZK6JuUYAEt4M7.jpg
43KB, 500x500px
>>60964505
#define true (rand()&2 ? true : false)
>>
>>60966639
Hardware interrupts don't need threads. They force your processor to stop doing what it was doing and start executing a predefined piece of code until this is either done, or perhaps another interrupt overrules this too. In the end it will return to the original program and continue running this as if nothing happened. It's made for situations like yours. The question is whether your system is able to use it. Many embedded systems run java these days, and I don't know if you can still easily use interrupts that way there. Last time I actually worked with them was still with 8 bit processors and assembly, then it was simple.
>>
>>60964415
#define TRUE 1

while (TRUE) {
...
}


FTFY FAGGOT
>>
>>60966212
Because there's no guarantee that it will exactly hit your end time. Change that != to <.
>>
.text
_start:
.globl _start
mov $4, %eax
mov $1, %ebx
mov $txt, %ecx
mov $16, %edx
loop:
int $0x80
mov $4, %eax
mov $1, %ebx
mov $txt, %ecx
mov $16, %edx
jmp loop
.data
txt: .ascii "OP is a faggot.\n"
>>
File: 1495172995340.png (100KB, 352x345px) Image search: [Google]
1495172995340.png
100KB, 352x345px
x = !!y;
>>
>>60964643
I started using that, just break out when some condition is satisfied anyways
>>
>>60966069

Gotos are patrician. You just don't understand them.
>>
I agree OP.

start:
...
if (break_condition) goto end;
goto start;

end:
...


is much more aesthetic.
>>
File: 1467684170909.png (197KB, 613x641px) Image search: [Google]
1467684170909.png
197KB, 613x641px
>>60964415
><br><br><br><br><br>hello world<br><br><br><br><br>
>>
>>60966069
If you've ever encountered code written by someone else 20+ years ago you'd understand my autistic nature towards gotos.
>>
while condition == True:
>>
double nigger = -1;
>>
while (1 < 2)
>>
[1..]
>>
>>60964504
The compiler will turn that into while(true) and skip evaluating the expression every loop.
>>
File: 1497322762833.jpg (569KB, 915x958px) Image search: [Google]
1497322762833.jpg
569KB, 915x958px
>>60966055
Saw an Indian do this in 3rd semester Java.
>>
reapeat "Oop is a faggot"
>>
>>60969569
gotos are still used mainly in driver programming where you don't have exceptions like in a higher level language.
They provide a single exiting code and cleaner code for things like this:
 
int *a, *b;
a = b = 0;
a = malloc (...);
if (!a)
goto cleanup;
b = malloc (...);
if (!b)
goto cleanup;

do_stuff

cleanup:
if (a)
free (a);
if (b)
free (b);
>>
>>60969569
This
>>60970046
would look like this without gotos:
a = malloc
if (a)
{
b = malloc
if (b)
{
Stuff

free(b);
}
free (a);
}

The more conditions for things that can go wrong and not being able to do 'Stuff' the more indented the code.
>>
>tfw I'm not allowed to use loops in this video game engine I'm using.

Scripts have to be loaded on demand or 60 times a second and if you put a loop in there it'll lock up the game.

It's a pity because I like scripting with loops.
>>
>>60969569
gotos can be pretty comfy if used properly. The problem lies in how easily they're abused and the awful result when they are.
>>
>>60970112
Yeah, all gotos I've encountered have been ways of doing indefinite do loops...
>>
nice bread
>>
>>60964415
my php normie colleagues always try to pull of shit like this:

using paranthesis like crazy thinking it makes any difference (also assigning within conditions, fuck that)
>if (($foo = ($this->a()))) { .. }
>>
>>60970046
Ok, I only program in higher level languages, so there's always a better option, but I'll take you at your word that they're the better option for driver programming.
>>
>>60970192
At the end of the day, the assembly generated and ran by whatever language you use makes extensive use of gotos (jumps), and it is sometimes convenient to represent the structure in the C code. As has been mentioned they also implement the same functionality as exceptions (conditional jumps).
>>
>>60964507
That can't be right
>>
>>60964877
Kek
>>
>>60964415
>>> l = [1, 2, 3, 4]
>>> while l:
... l.append(l.pop(0))
>>
do {
if (cond) break;
...
} while(false);

goto is bad, alright?
>>
Nothing wrong with using while(true)
>>
>his language doesn't have the `loop` operator and labeled blocks
'outer: loop {
if condition {
break;
}
loop {
if condition1 {
break 'outer;
} else {
break;
}
}
}
>>
File: __find_end.png (18KB, 720x441px) Image search: [Google]
__find_end.png
18KB, 720x441px
here's some libstd code for ya
>>
#include <stdbool.h>

static bool true()
{
return !1; /* I'm so random ^_^ */
}

int main(void)
{
while (true != true())
{
true ();
}
return false;
}
>>
>>60964415
while(1 + (1 - (3 - 2) * (176-175))){
printf("Oy vey\n");
}
>>
>>60967725
Disgusting syntax
>>
>>60964924
>>60964924
compiler will optimize this, nigger
>>
>>60964490
>!!!!!!

what
Thread posts: 74
Thread images: 9


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.