Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

correctly remembered that do-while is the loop construct for an indefinite number of loops but at least 1

Adbot
ADBOT LOVES YOU

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


I honestly had an absolute hot streak of change tickets slammed through 30 minutes before the cutoff for "normal" changes with rollback written as "it's too complicated, we fix forward" for most of them and the testing evidence all written as "see Jira" knowing perfectly well nobody would ever check it and that the evidence was generally inscrutable to anyone that would look at it one weird trick to make end users happy by increasing delivery speed, change management hate it!

now I watch the dev team spend 12 hours to deploy one service component to send emails and somehow gently caress it up such that a) it takes 12 hours jfc how, and b) it keeps sending emails with no content lmao

I'm so glad I don't have to manage that, I just get to occasionally lose my poo poo about it and things like "why is there not one single entity relationship or database design diagram for this massive data mode change?"

well-read undead
Dec 13, 2022

Powerful Two-Hander posted:

I'm so glad I don't have to manage that, I just get to occasionally lose my poo poo about it and things like "why is there not one single entity relationship or database design diagram for this massive data mode change?"

and doing this is easier than it's ever been, you can just embed mermaid diagrams in tons of stuff now, including readmes, and have github and your ide render them inline. tada, zero effort erd, would you look at that

cool av
Mar 2, 2013

Captain Foo posted:

correctly remembered that do-while is the loop construct for an indefinite number of loops but at least 1

i can't remember ever seeing a do-while that made better sense than a similar while

The Fool
Oct 16, 2003


I control the execution of my while loops by placing a break statement at the front or end

ryanrs
Jul 12, 2011

I put a Duff's Device in shipping code (early versions of iChat AV).

Ultrapotassium
Feb 13, 2022

ryanrs posted:

I put a Duff's Device in shipping code (early versions of iChat AV).

Dear Lord.

Talk about awful programming.

Ultrapotassium fucked around with this message at 08:19 on Aug 2, 2024

ryanrs
Jul 12, 2011

I tried it out just for lols, but it profiled 0.5% faster, so we shipped it.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

there has on multiple occasions been a duff’s device in the Linux kernel, I’m pretty sure. (possible that they were out-of-tree drivers but I don’t think so)

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

cool av posted:

i can't remember ever seeing a do-while that made better sense than a similar while

Not my problem lol

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Captain Foo posted:

Not my problem lol

he'll yeah

its future yous problem

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

i mean it’s literally the correct construct for the use case

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Captain Foo posted:

i mean it’s literally the correct construct for the use case

imo any type of loop can be written as any other type if you name & init the variables correctly, the latter being more important cause the compiler is just gonna make a for loop anyway

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
the compiler is just gonna use a goto unless you're on a weird platform with hardware loops

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Jabor posted:

the compiler is just gonna use a goto unless you're on a weird platform with hardware loops

i mean like dec+jne is basically a for loop

Share Bear
Apr 27, 2004

if youre gonna do while just do the thing before the while which immediately terminates based on current state

weirdly bad syntactic sugar imo

Share Bear
Apr 27, 2004

theres prob some assembly related purposeful bad output reason for its existence

“our compiled couldnt figure out this only ran once” kinda deal

well-read undead
Dec 13, 2022

why are you people afraid of do while

it's not going to hurt you

Kazinsal
Dec 13, 2011

do while is great in the context of mmio where you know you have at least one input to pull or whatever but the data you read directly affects how many times you have to read next etc

CPColin
Sep 9, 2003

Big ol' smile.
The worst thing about do-while is that it needs a semicolon at the end

The Fool
Oct 16, 2003


best thing about javascript imo

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

CPColin posted:

The worst thing about do-while is that it needs a semicolon at the end

but that makes my multiline macros look like function calls

ryanrs
Jul 12, 2011

yep, very handy when your preprocessor macro needs some local variables

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
I've only ever needed foreach, we can get rid of all the others imo.

well-read undead
Dec 13, 2022

pokeyman posted:

but that makes my multiline macros look like function calls

now that's what i call functional programming

Soricidus
Oct 21, 2010
freedom-hating statist shill
code:
do {
   if (!condition) break;
   // loop body here
} while (1);
or gtfo imo

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Or if you need to possibly bail early from a block of code and don't have goto:

code:

do {
    // Whatever
    if(uh_oh) break;
} while (false);

Sapozhnik
Jan 2, 2005

Nap Ghost
a programming structure that you can potentially make an early return from. if only such a thing existed.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sapozhnik posted:

a programming structure that you can potentially make an early return from. if only such a thing existed.

liskov called and just wanted you to know that they’re very disappointed that you don’t care about ergonomics or performance

Truman Peyote
Oct 11, 2006



i honestly can't remember the last time i saw a loop that wasn't a for or foreach

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Wheany posted:

Or if you need to possibly bail early from a block of code and don't have goto:

code:
do {
    // Whatever
    if(uh_oh) break;
} while (false);

also `do while { } (0)` is the only honourable solution if you want multiple statements within a macro expansion :getin:

Tunicate
May 15, 2012

Truman Peyote posted:

i honestly can't remember the last time i saw a loop that wasn't a for or foreach

While (true) is the flow control of champions

polyester concept
Mar 29, 2017

i had to write a while loop last week. probably the first one in years.

well-read undead
Dec 13, 2022

go programmers reading this thread looking very confused

FlapYoJacks
Feb 12, 2009
I use gotos quite often in C in kernel land. much easier to nail out in multiple parts of a drivers probe function using a goto.

Hadlock
Nov 9, 2004

Truman Peyote posted:

i honestly can't remember the last time i saw a loop that wasn't a for or foreach

bro do you even write services in bash

comon' son

Presto
Nov 22, 2002

Keep calm and Harry on.

Truman Peyote posted:

i honestly can't remember the last time i saw a loop that wasn't a for or foreach

Eh, they all have their uses. I use 'for' when I know in advance when the loop will stop and 'while' when :iiam:.

CPColin
Sep 9, 2003

Big ol' smile.
Also while(true) because some rear end in a top hat said we can't just GOTO 10 at the end of our programs :mad:

Shaggar
Apr 26, 2006
instead of while(true) use while(!cancellationToken.IsCancellationRequested)

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.
no

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply