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
MrMoo
Sep 14, 2000

Unfortunately no code, but not lacking on humor.

quote:

searching concurrent linked list; I don't want to make copies of the list. Too expensive. Mom pays for my hardware.

http://stackoverflow.com/questions/4178132/searching-concurrent-linked-list

Adbot
ADBOT LOVES YOU

Scaevolus
Apr 16, 2007

C++ written by a former Fortran programmer:

code:
// this is in a function that loads settings from a file
if (!strcmp(str1, "locale_test"))
{
	double val = atof(str2);
	if (val == 0.5) locale_dot = true;
	else locale_dot = false;
}
else if (IFSresult) IFSresult = false;
else if (!strcmp(str1, "image_width")) params.image_width = atoi(str2);
else if (!strcmp(str1, "image_height")) params.image_height = atoi(str2);
else if (!strcmp(str1, "x_min")) params.doubles.amin = atof2(str2, locale_dot, &special->amin);
else if (!strcmp(str1, "x_max")) params.doubles.amax = atof2(str2, locale_dot, &special->amax);
else if (!strcmp(str1, "y_min")) params.doubles.bmin = atof2(str2, locale_dot, &special->bmin);
else if (!strcmp(str1, "y_max")) params.doubles.bmax = atof2(str2, locale_dot, &special->bmax);
else if (!strcmp(str1, "z_min")) params.doubles.cmin = atof2(str2, locale_dot, &special->cmin);
else if (!strcmp(str1, "z_max")) params.doubles.cmax = atof2(str2, locale_dot, &special->cmax);
[...200 similar lines...]
else if (!strcmp(str1, "file_envmap")) strcpy(params.file_envmap, str2);
else if (!strcmp(str1, "file_lightmap")) strcpy(params.file_lightmap, str2);
else if (!strcmp(str1, "file_animation_path")) strcpy(params.file_path, str2);
else if (!strcmp(str1, "file_keyframes")) strcpy(params.file_keyframes, str2);
else if (!strcmp(str1, "file_sound")) strcpy(params.file_sound, str2);
else if (!strcmp(str1, "palette")) GetPaletteFromString(params.palette, str2);
else
{
	printf("Warning! Unknown parameter: %s\n", str1);
	WriteLog("Warning! Unknown parameter:");
	WriteLog(str1);
}
There's a corresponding function to write out settings to a file, that looks pretty similar.

(You don't want to see the GTK interface code...)

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Scaevolus: Maybe I'm the coding horror here, but that could be a lot worse. Assuming all the settings are already stored in a single object, that seems like a halfway reasonable way to serialize and deserialize them without worring about breaking everything when you add a field. The main problem would appear to be a failure to organize the data with any kind of heirarchy.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Internet Janitor posted:

Scaevolus: Maybe I'm the coding horror here, but that could be a lot worse. Assuming all the settings are already stored in a single object, that seems like a halfway reasonable way to serialize and deserialize them without worring about breaking everything when you add a field. The main problem would appear to be a failure to organize the data with any kind of heirarchy.

Well, first of all, there's this line:

code:
else if (IFSresult) IFSresult = false;
Which as far as I can tell is a pretty horrible hack to let it not break on the one setting that has an additional line of data. And that's in addition to the reinventing-the-wheelness.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Internet Janitor posted:

Maybe I'm the coding horror here,

"What is a dispatch table? Hell, what is a hash table even?"

Vanadium
Jan 8, 2005

Did the C++ thread not just tell a guy to go ahead with lots of string comparisons instead of bothering with a hashmap or whatever

king_kilr
May 25, 2007

Vanadium posted:

Did the C++ thread not just tell a guy to go ahead with lots of string comparisons instead of bothering with a hashmap or whatever

Are we talking about the thing where someone recommended some god-forsaken academic wackadoo datastruture that was completely inappropriate in place of a hashtable?

shrughes
Oct 11, 2008

(call/cc call/cc)

Otto Skorzeny posted:

"What is a dispatch table? Hell, what is a hash table even?"

What do you think this is, Python? Making functions is expensive and verbose in C++. Do you want a zillion little classes overriding operator()?

If that code's running noticeably slow the author can just split the conditionals into those with strings less than "l" and those greater, and then do if (0 > strcmp(str1, "l")) { ... } else { ... } for an instant doubling of performance. This could be done a few more times and it's much better than using some crazy advanced parser.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

shrughes posted:

What do you think this is, Python? Making functions is expensive and verbose in C++.

While a dispatch table is inconvenient in this case without C++0x lambdas, a hash of values is still more convenient than two hundred and change else ifs and strcmps, without taking the improvement in asymptotic performance into account.

shrughes posted:

Do you want a zillion little classes overriding operator()?

"What is a function pointer?"

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
You needn't even get that fancy; a simple parser class could clean up the duplicated code and symbol vomit:

code:
ParamParser p;

p.Integer("image_width", &(params.image_width));
p.Integer("image_height", &(params.image_height));
p.Double("x_min", &(params.doubles.amin), &(special->amin));
p.String("file_envmap", &(params.file_envmap));
// ...

while (/* get str1 and str2 here */)
{
  p.Parse(str1, str2);
}

Scaevolus
Apr 16, 2007

Janin posted:

You needn't even get that fancy; a simple parser class could clean up the duplicated code and symbol vomit:

code:
ParamParser p;

p.Integer("image_width", &(params.image_width));
p.Integer("image_height", &(params.image_height));
p.Double("x_min", &(params.doubles.amin), &(special->amin));
p.String("file_envmap", &(params.file_envmap));
// ...

while (/* get str1 and str2 here */)
{
  p.Parse(str1, str2);
}
This is my main issue. It's not that there's anything wrong with the code being explicit, it's just that there's so much redundancy in it.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

shrughes posted:

What do you think this is, Python? Making functions is expensive and verbose in C++.
What the gently caress kind of expensive are you talking about?

POKEMAN SAM
Jul 8, 2004

Mustach posted:

What the gently caress kind of expensive are you talking about?

whoooooosh

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Ah yes, that was a hilarious joke, my bad.

raminasi
Jan 25, 2005

a last drink with no ice
I don't know if I'm the only one who didn't notice that 200 lines had been removed from that. It's a lot worse that way.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



GrumpyDoctor posted:

I don't know if I'm the only one who didn't notice that 200 lines had been removed from that. It's a lot worse that way.

I don't understand how someone can be more than about 10% of the way into that and not stop and look for a better way.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Munkeymon: If you're reading and writing a preferences object with 200 fields, it's going to take about 200 lines, even if you use something more succinct like what Janin suggested. We could store all that stuff as a JSON associative array and have even less code per property, but we'd still have to load and unload all the fields from it. If you have a built-in serialization system, awesome, but most of the time those generate output that only works with the right version of the class that made it, so forget adding or changing fields.

shrughes
Oct 11, 2008

(call/cc call/cc)

Mustach posted:

What the gently caress kind of expensive are you talking about?

In terms of programmer time. It is more annoying to have to jump around from the setting keyword to the code associated with the setting. And it is more typing.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Okay. I disagree with you a little bit on that, but not enough to argue (or to change similarly-reasoned code if I were to run into it at work).

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Internet Janitor posted:

Munkeymon: If you're reading and writing a preferences object with 200 fields, it's going to take about 200 lines, even if you use something more succinct like what Janin suggested. We could store all that stuff as a JSON associative array and have even less code per property, but we'd still have to load and unload all the fields from it. If you have a built-in serialization system, awesome, but most of the time those generate output that only works with the right version of the class that made it, so forget adding or changing fields.

So, after a quarter century, nobody has come up with any way to load data from a file into class fields in C++ that doesn't involve copying and pasting (potentially) hundreds of lines of code by hand?

Dicky B
Mar 23, 2004

That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime?

litghost
May 26, 2004
Builder

Dicky B posted:

That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime?

code:
std::unordered_map<std::string,std::string>
?

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Dicky B posted:

That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime?
Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.

evensevenone
May 12, 2001
Glass is a solid.

Internet Janitor posted:

Munkeymon: If you're reading and writing a preferences object with 200 fields, it's going to take about 200 lines, even if you use something more succinct like what Janin suggested. We could store all that stuff as a JSON associative array and have even less code per property, but we'd still have to load and unload all the fields from it. If you have a built-in serialization system, awesome, but most of the time those generate output that only works with the right version of the class that made it, so forget adding or changing fields.

You don't have to do it with a 200-line long conditional construction though.

litghost
May 26, 2004
Builder

Janin posted:

Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.

A partial example of this is google's protocol buffers. Because it creates reflectable run-time structures, it can serialize to pretty much anything. However it does not boil down to a struct, so it is not quiet as simple to work with as a struct would be.

Dicky B
Mar 23, 2004

litghost posted:

?
We're talking about populating primitive data fields though..

Janin posted:

Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.
That's cheating :argh: but yeah ok. This could be situationally preferable to using a hash table or equivalent. I like it!

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
code:
    function hasRights($i) {
      return ((pow(2, $i) & $this->getRights()) == pow(2, $i));
    }
That function is used like this:

if(hasRights(5)){...}

What does '5' mean? Who knows!

Well, actually there is an explanation about the bits in the rights-field in a comment near 'hasRights', but it's off-by-one. And for some reason it does not use the least significant bit at all :rolleye:

This codebase is pretty :krad:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Janin posted:

Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.
You could also parse the header defining the struct and generate serialization code from that.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Plorkyeran posted:

You could also parse the header defining the struct and generate serialization code from that.
Would you rather spend 1) two hours writing a simple preprocessor or 2) two years writing a partial implementation of C++'s grammar?

Before you answer, remember that C++'s template system is Turing-complete.

evensevenone
May 12, 2001
Glass is a solid.

Wheany posted:

Well, actually there is an explanation about the bits in the rights-field in a comment near 'hasRights', but it's off-by-one. And for some reason it does not use the least significant bit at all :rolleye:

obviously it's a checksum.

pseudorandom name
May 6, 2007

Janin posted:

Would you rather spend 1) two hours writing a simple preprocessor or 2) two years writing a partial implementation of C++'s grammar?

Before you answer, remember that C++'s template system is Turing-complete.

You could always pull the list of fields out of the debug metadata.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Janin posted:

Would you rather spend 1) two hours writing a simple preprocessor or 2) two years writing a partial implementation of C++'s grammar?

Before you answer, remember that C++'s template system is Turing-complete.
I was not trying to suggest that it was a better option.

I would like to point out, though, that parsing C++ does not have to require you writing the parser from scratch.

npe
Oct 15, 2004
Dear Penthouse:

I never thought it would happen to me. For years, I've been reading sordid tales of the "for case" paradigm, but I never thought they actually happened! But today, I found this in svn...

quote:

Changeset 19314 for AutomatedUser

Timestamp:
11/02/10 14:33:14 (2 weeks ago)

-Added 50 more workers to make 100. I put the calls to start each worker in a while loop. This is not ideal. I really wanted to make an array (or other container) of workers and handle them throughout the code using loops. But VB doesn't like it when you try to put "Friend WithEvents?" types of objects into an array. There are ways of working with that and if I need to make > 100 workers I'll check them out. Each worker is its own thread.

code:
 		        Me.BackgroundWorker51 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker52 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker53 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker54 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker55 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker56 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker57 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker58 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker59 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker60 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker61 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker62 = New System.ComponentModel.BackgroundWorker() 
 		        Me.BackgroundWorker63 = New System.ComponentModel.BackgroundWorker() 

...etc
code:
 		    Friend WithEvents BackgroundWorker51 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker52 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker53 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker54 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker55 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker56 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker57 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker58 As System.ComponentModel.BackgroundWorker 
 		    Friend WithEvents BackgroundWorker59 As System.ComponentModel.BackgroundWorker 

...etc
...wait for it...

code:
 		    Private Sub BackgroundWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker100.DoWork, _ 
 		                        BackgroundWorker99.DoWork, BackgroundWorker98.DoWork, BackgroundWorker97.DoWork, BackgroundWorker96.DoWork, BackgroundWorker95.DoWork, _ 
 		                        BackgroundWorker94.DoWork, BackgroundWorker93.DoWork, BackgroundWorker92.DoWork, BackgroundWorker91.DoWork, BackgroundWorker90.DoWork, _ 
 		                        BackgroundWorker89.DoWork, BackgroundWorker88.DoWork, BackgroundWorker87.DoWork, BackgroundWorker86.DoWork, BackgroundWorker85.DoWork, _ 
 		                        BackgroundWorker84.DoWork, BackgroundWorker83.DoWork, BackgroundWorker82.DoWork, BackgroundWorker81.DoWork, BackgroundWorker80.DoWork, _ 
 		                        BackgroundWorker79.DoWork, BackgroundWorker78.DoWork, BackgroundWorker77.DoWork, BackgroundWorker76.DoWork, BackgroundWorker75.DoWork, _ 
 		                        BackgroundWorker74.DoWork, BackgroundWorker73.DoWork, BackgroundWorker72.DoWork, BackgroundWorker71.DoWork, BackgroundWorker70.DoWork, _ 
 		                        BackgroundWorker69.DoWork, BackgroundWorker68.DoWork, BackgroundWorker67.DoWork, BackgroundWorker66.DoWork, BackgroundWorker65.DoWork, _ 
 		                        BackgroundWorker64.DoWork, BackgroundWorker63.DoWork, BackgroundWorker62.DoWork, BackgroundWorker61.DoWork, BackgroundWorker60.DoWork, _ 
 		                        BackgroundWorker59.DoWork, BackgroundWorker58.DoWork, BackgroundWorker57.DoWork, BackgroundWorker56.DoWork, BackgroundWorker55.DoWork, _ 
 		                        BackgroundWorker54.DoWork, BackgroundWorker53.DoWork, BackgroundWorker52.DoWork, BackgroundWorker51.DoWork, BackgroundWorker50.DoWork, _ 
 		                        BackgroundWorker49.DoWork, BackgroundWorker48.DoWork, BackgroundWorker47.DoWork, BackgroundWorker46.DoWork, _ 
 		                        BackgroundWorker45.DoWork, BackgroundWorker44.DoWork, BackgroundWorker43.DoWork, BackgroundWorker42.DoWork, _ 
 		                        BackgroundWorker41.DoWork, BackgroundWorker40.DoWork, BackgroundWorker39.DoWork, BackgroundWorker38.DoWork, _ 
 		                        BackgroundWorker37.DoWork, BackgroundWorker36.DoWork, BackgroundWorker35.DoWork, BackgroundWorker34.DoWork, _ 
 		                        BackgroundWorker33.DoWork, BackgroundWorker32.DoWork, BackgroundWorker31.DoWork, BackgroundWorker30.DoWork, _ 
 		                        BackgroundWorker29.DoWork, BackgroundWorker28.DoWork, BackgroundWorker27.DoWork, BackgroundWorker26.DoWork, _ 
 		                        BackgroundWorker25.DoWork, BackgroundWorker24.DoWork, BackgroundWorker23.DoWork, BackgroundWorker22.DoWork, _ 
 		                        BackgroundWorker21.DoWork, BackgroundWorker20.DoWork, BackgroundWorker19.DoWork, BackgroundWorker18.DoWork, _ 
 		                        BackgroundWorker17.DoWork, BackgroundWorker16.DoWork, BackgroundWorker15.DoWork, BackgroundWorker14.DoWork, _ 
 		                        BackgroundWorker13.DoWork, BackgroundWorker12.DoWork, BackgroundWorker11.DoWork, BackgroundWorker10.DoWork, _ 
 		                        BackgroundWorker9.DoWork, BackgroundWorker8.DoWork, BackgroundWorker7.DoWork, BackgroundWorker6.DoWork, _ 
 		                        BackgroundWorker5.DoWork, BackgroundWorker4.DoWork, BackgroundWorker3.DoWork, BackgroundWorker2.DoWork, _ 
 		                        BackgroundWorker1.DoWork 
...here it is!

code:
 		        While (ctr > 0) 
 		            Select Case (ctr) 
 		                Case 100 : BackgroundWorker100.RunWorkerAsync() 
 		                Case 99 : BackgroundWorker99.RunWorkerAsync() 
 		                Case 98 : BackgroundWorker98.RunWorkerAsync() 
 		                Case 97 : BackgroundWorker97.RunWorkerAsync() 
 		                Case 96 : BackgroundWorker96.RunWorkerAsync() 
 		                Case 95 : BackgroundWorker95.RunWorkerAsync() 
 		                Case 94 : BackgroundWorker94.RunWorkerAsync() 
 		                Case 93 : BackgroundWorker93.RunWorkerAsync() 
 		                Case 92 : BackgroundWorker92.RunWorkerAsync() 
 		                Case 91 : BackgroundWorker91.RunWorkerAsync() 
 		                Case 90 : BackgroundWorker90.RunWorkerAsync() 
 		                Case 89 : BackgroundWorker89.RunWorkerAsync() 
 		                Case 88 : BackgroundWorker88.RunWorkerAsync() 
 		                Case 87 : BackgroundWorker87.RunWorkerAsync() 
 		                Case 86 : BackgroundWorker86.RunWorkerAsync() 
 		                Case 85 : BackgroundWorker85.RunWorkerAsync() 
 		                Case 84 : BackgroundWorker84.RunWorkerAsync() 
 		                Case 83 : BackgroundWorker83.RunWorkerAsync() 
 		                Case 82 : BackgroundWorker82.RunWorkerAsync() 
 		                Case 81 : BackgroundWorker81.RunWorkerAsync() 
 		                Case 80 : BackgroundWorker80.RunWorkerAsync() 
 		                Case 79 : BackgroundWorker79.RunWorkerAsync() 
 		                Case 78 : BackgroundWorker78.RunWorkerAsync() 
 		                Case 77 : BackgroundWorker77.RunWorkerAsync() 
 		                Case 76 : BackgroundWorker76.RunWorkerAsync() 
 		                Case 75 : BackgroundWorker75.RunWorkerAsync() 
 		                Case 74 : BackgroundWorker74.RunWorkerAsync() 
 		                Case 73 : BackgroundWorker73.RunWorkerAsync() 
 		                Case 72 : BackgroundWorker72.RunWorkerAsync() 
 		                Case 71 : BackgroundWorker71.RunWorkerAsync() 
 		                Case 70 : BackgroundWorker70.RunWorkerAsync() 
 		                Case 69 : BackgroundWorker69.RunWorkerAsync() 
 		                Case 68 : BackgroundWorker68.RunWorkerAsync() 
 		                Case 67 : BackgroundWorker67.RunWorkerAsync() 
 		                Case 66 : BackgroundWorker66.RunWorkerAsync() 
 		                Case 65 : BackgroundWorker65.RunWorkerAsync() 
 		                Case 64 : BackgroundWorker64.RunWorkerAsync() 
 		                Case 63 : BackgroundWorker63.RunWorkerAsync() 
 		                Case 62 : BackgroundWorker62.RunWorkerAsync() 
 		                Case 61 : BackgroundWorker61.RunWorkerAsync() 
 		                Case 60 : BackgroundWorker60.RunWorkerAsync() 
 		                Case 59 : BackgroundWorker59.RunWorkerAsync() 
 		                Case 58 : BackgroundWorker58.RunWorkerAsync() 
 		                Case 57 : BackgroundWorker57.RunWorkerAsync() 
 		                Case 56 : BackgroundWorker56.RunWorkerAsync() 
 		                Case 55 : BackgroundWorker55.RunWorkerAsync() 
 		                Case 54 : BackgroundWorker54.RunWorkerAsync() 
 		                Case 53 : BackgroundWorker53.RunWorkerAsync() 
 		                Case 52 : BackgroundWorker52.RunWorkerAsync() 
 		                Case 51 : BackgroundWorker51.RunWorkerAsync() 
 		                Case 50 : BackgroundWorker50.RunWorkerAsync() 
 		                Case 49 : BackgroundWorker49.RunWorkerAsync() 
 		                Case 48 : BackgroundWorker48.RunWorkerAsync() 
 		                Case 47 : BackgroundWorker47.RunWorkerAsync() 
 		                Case 46 : BackgroundWorker46.RunWorkerAsync() 
 		                Case 45 : BackgroundWorker45.RunWorkerAsync() 
 		                Case 44 : BackgroundWorker44.RunWorkerAsync() 
 		                Case 43 : BackgroundWorker43.RunWorkerAsync() 
 		                Case 42 : BackgroundWorker42.RunWorkerAsync() 
 		                Case 41 : BackgroundWorker41.RunWorkerAsync() 
 		                Case 40 : BackgroundWorker40.RunWorkerAsync() 
 		                Case 39 : BackgroundWorker39.RunWorkerAsync() 
 		                Case 38 : BackgroundWorker38.RunWorkerAsync() 
 		                Case 37 : BackgroundWorker37.RunWorkerAsync() 
 		                Case 36 : BackgroundWorker36.RunWorkerAsync() 
 		                Case 35 : BackgroundWorker35.RunWorkerAsync() 
 		                Case 34 : BackgroundWorker34.RunWorkerAsync() 
 		                Case 33 : BackgroundWorker33.RunWorkerAsync() 
 		                Case 32 : BackgroundWorker32.RunWorkerAsync() 
 		                Case 31 : BackgroundWorker31.RunWorkerAsync() 
 		                Case 30 : BackgroundWorker30.RunWorkerAsync() 
 		                Case 29 : BackgroundWorker29.RunWorkerAsync() 
 		                Case 28 : BackgroundWorker28.RunWorkerAsync() 
 		                Case 27 : BackgroundWorker27.RunWorkerAsync() 
 		                Case 26 : BackgroundWorker26.RunWorkerAsync() 
 		                Case 25 : BackgroundWorker25.RunWorkerAsync() 
 		                Case 24 : BackgroundWorker24.RunWorkerAsync() 
 		                Case 23 : BackgroundWorker23.RunWorkerAsync() 
 		                Case 22 : BackgroundWorker22.RunWorkerAsync() 
 		                Case 21 : BackgroundWorker21.RunWorkerAsync() 
 		                Case 20 : BackgroundWorker20.RunWorkerAsync() 
 		                Case 19 : BackgroundWorker19.RunWorkerAsync() 
 		                Case 18 : BackgroundWorker18.RunWorkerAsync() 
 		                Case 17 : BackgroundWorker17.RunWorkerAsync() 
 		                Case 16 : BackgroundWorker16.RunWorkerAsync() 
 		                Case 15 : BackgroundWorker15.RunWorkerAsync() 
 		                Case 14 : BackgroundWorker14.RunWorkerAsync() 
 		                Case 13 : BackgroundWorker13.RunWorkerAsync() 
 		                Case 12 : BackgroundWorker12.RunWorkerAsync() 
 		                Case 11 : BackgroundWorker11.RunWorkerAsync() 
 		                Case 10 : BackgroundWorker10.RunWorkerAsync() 
 		                Case 9 : BackgroundWorker9.RunWorkerAsync() 
 		                Case 8 : BackgroundWorker8.RunWorkerAsync() 
 		                Case 7 : BackgroundWorker7.RunWorkerAsync() 
 		                Case 6 : BackgroundWorker6.RunWorkerAsync() 
 		                Case 5 : BackgroundWorker5.RunWorkerAsync() 
 		                Case 4 : BackgroundWorker4.RunWorkerAsync() 
 		                Case 3 : BackgroundWorker3.RunWorkerAsync() 
 		                Case 2 : BackgroundWorker2.RunWorkerAsync() 
 		                Case 1 : BackgroundWorker1.RunWorkerAsync() 
 		            End Select 
 		            ctr -= 1 
 		        End While 
It was every bit as wonderful as I expected it to be!

Karanth
Dec 25, 2003
I need to finish Xenogears sometime, damn it.
The for-case might be the least offensive part of that mess.

POKEMAN SAM
Jul 8, 2004

npe posted:


It was every bit as wonderful as I expected it to be!

Holy poo poo good game you win.

zeekner
Jul 14, 2007

npe posted:

Dear Penthouse:
:drat:
It was every bit as wonderful as I expected it to be!

Do VB switch-cases fall-through? If so, there are no words to describe the horror.

Dicky B
Mar 23, 2004

That is truly tragic.
code:
			While (ctr > 0) 
				Select Case (ctr) 
				    Case 100 : BackgroundWorker100.RunWorkerAsync() 
				    Case 99 : BackgroundWorker99.RunWorkerAsync() 
				    Case 98 : BackgroundWorker98.RunWorkerAsync() 
				    Case 97 : BackgroundWorker97.RunWorkerAsync() 
				    Case 96 : BackgroundWorker96.RunWorkerAsync() 
				    Case 95 : BackgroundWorker95.RunWorkerAsync() 
				    Case 94 : BackgroundWorker94.RunWorkerAsync() 
				    Case 93 : BackgroundWorker93.RunWorkerAsync() 
				    Case 92 : BackgroundWorker92.RunWorkerAsync() 
				    Case 91 : BackgroundWorker91.RunWorkerAsync() 
				    Case 90 : BackgroundWorker90.RunWorkerAsync() 
				    Case 89 : BackgroundWorker89.RunWorkerAsync() 
				    Case 88 : BackgroundWorker88.RunWorkerAsync() 
				    Case 87 : BackgroundWorker87.RunWorkerAsync() 
				    Case 86 : BackgroundWorker86.RunWorkerAsync() 
				    Case 85 : BackgroundWorker85.RunWorkerAsync() 
				    Case 84 : BackgroundWorker84.RunWorkerAsync() 
				    Case 83 : BackgroundWorker83.RunWorkerAsync() 
				    Case 82 : BackgroundWorker82.RunWorkerAsync() 
				    Case 81 : BackgroundWorker81.RunWorkerAsync() 
				    Case 80 : BackgroundWorker80.RunWorkerAsync() 
				    Case 79 : BackgroundWorker79.RunWorkerAsync() 
				    Case 78 : BackgroundWorker78.RunWorkerAsync() 
				    Case 77 : BackgroundWorker77.RunWorkerAsync() 
				    Case 76 : BackgroundWorker76.RunWorkerAsync() 
				    Case 75 : BackgroundWorker75.RunWorkerAsync() 
 _____     		            Case 74 : BackgroundWorker74.RunWorkerAsync() 
 \ U \__      _____                 Case 73 : BackgroundWorker73.RunWorkerAsync() 
  \   \/_______\___\_____________   Case 72 : BackgroundWorker72.RunWorkerAsync() 
  < /_/   .....................  `-.Case 71 : BackgroundWorker71.RunWorkerAsync() 
   `-----------,----,--------------'Case 70 : BackgroundWorker70.RunWorkerAsync() 
             _/____/		    Case 69 : BackgroundWorker69.RunWorkerAsync() 
				    Case 68 : BackgroundWorker68.RunWorkerAsync() 
				    Case 67 : BackgroundWorker67.RunWorkerAsync() 
				    Case 66 : BackgroundWorker66.RunWorkerAsync() 
				    Case 65 : BackgroundWorker65.RunWorkerAsync() 
				    Case 64 : BackgroundWorker64.RunWorkerAsync() 
				    Case 63 : BackgroundWorker63.RunWorkerAsync() 
				    Case 62 : BackgroundWorker62.RunWorkerAsync() 
				    Case 61 : BackgroundWorker61.RunWorkerAsync() 
				    Case 60 : BackgroundWorker60.RunWorkerAsync() 
				    Case 59 : BackgroundWorker59.RunWorkerAsync() 
				    Case 58 : BackgroundWorker58.RunWorkerAsync() 
				    Case 57 : BackgroundWorker57.RunWorkerAsync() 
				    Case 56 : BackgroundWorker56.RunWorkerAsync() 
				    Case 55 : BackgroundWorker55.RunWorkerAsync() 
				    Case 54 : BackgroundWorker54.RunWorkerAsync() 
				    Case 53 : BackgroundWorker53.RunWorkerAsync() 
				    Case 52 : BackgroundWorker52.RunWorkerAsync() 
				    Case 51 : BackgroundWorker51.RunWorkerAsync() 
				    Case 50 : BackgroundWorker50.RunWorkerAsync() 
				    Case 49 : BackgroundWorker49.RunWorkerAsync() 
				    Case 48 : BackgroundWorker48.RunWorkerAsync() 
				    Case 47 : BackgroundWorker47.RunWorkerAsync() 
				    Case 46 : BackgroundWorker46.RunWorkerAsync() 
				    Case 45 : BackgroundWorker45.RunWorkerAsync() 
				    Case 44 : BackgroundWorker44.RunWorkerAsync() 
				    Case 43 : BackgroundWorker43.RunWorkerAsync() 
				    Case 42 : BackgroundWorker42.RunWorkerAsync() 
				    Case 41 : BackgroundWorker41.RunWorkerAsync() 
				    Case 40 : BackgroundWorker40.RunWorkerAsync() 
				    Case 39 : BackgroundWorker39.RunWorkerAsync() 
				    Case 38 : BackgroundWorker38.RunWorkerAsync() 
				    Case 37 : BackgroundWorker37.RunWorkerAsync() 
				    Case 36 : BackgroundWorker36.RunWorkerAsync() 
				    Case 35 : BackgroundWorker35.RunWorkerAsync() 
				    Case 34 : BackgroundWorker34.RunWorkerAsync() 
				    Case 33 : BackgroundWorker33.RunWorkerAsync() 
				    Case 32 : BackgroundWorker32.RunWorkerAsync() 
				    Case 31 : BackgroundWorker31.RunWorkerAsync() 
				    Case 30 : BackgroundWorker30.RunWorkerAsync() 
				    Case 29 : BackgroundWorker29.RunWorkerAsync() 
				    Case 28 : BackgroundWorker28.RunWorkerAsync() 
				    Case 27 : BackgroundWorker27.RunWorkerAsync() 
				    Case 26 : BackgroundWorker26.RunWorkerAsync() 
				    Case 25 : BackgroundWorker25.RunWorkerAsync() 
				    Case 24 : BackgroundWorker24.RunWorkerAsync() 
				    Case 23 : BackgroundWorker23.RunWorkerAsync() 
				    Case 22 : BackgroundWorker22.RunWorkerAsync() 
				    Case 21 : BackgroundWorker21.RunWorkerAsync() 
				    Case 20 : BackgroundWorker20.RunWorkerAsync() 
				    Case 19 : BackgroundWorker19.RunWorkerAsync() 
				    Case 18 : BackgroundWorker18.RunWorkerAsync() 
				    Case 17 : BackgroundWorker17.RunWorkerAsync() 
				    Case 16 : BackgroundWorker16.RunWorkerAsync() 
				    Case 15 : BackgroundWorker15.RunWorkerAsync() 
				    Case 14 : BackgroundWorker14.RunWorkerAsync() 
				    Case 13 : BackgroundWorker13.RunWorkerAsync() 
				    Case 12 : BackgroundWorker12.RunWorkerAsync() 
				    Case 11 : BackgroundWorker11.RunWorkerAsync() 
				    Case 10 : BackgroundWorker10.RunWorkerAsync() 
				    Case 9 : BackgroundWorker9.RunWorkerAsync() 
				    Case 8 : BackgroundWorker8.RunWorkerAsync() 
				    Case 7 : BackgroundWorker7.RunWorkerAsync() 
				    Case 6 : BackgroundWorker6.RunWorkerAsync() 
				    Case 5 : BackgroundWorker5.RunWorkerAsync() 
				    Case 4 : BackgroundWorker4.RunWorkerAsync() 
				    Case 3 : BackgroundWorker3.RunWorkerAsync() 
				    Case 2 : BackgroundWorker2.RunWorkerAsync() 
				    Case 1 : BackgroundWorker1.RunWorkerAsync() 
				End Select 
				ctr -= 1 
			End While 
:911:

Bhaal
Jul 13, 2001
I ain't going down alone
Dr. Infant, MD
I'm kind of surprised I've never come across this before. From the Zend framework:
php:
<?
switch (true) {
    case (0 == $argc):
        break;
    case (1 <= $argc):
        $validator  = array_shift($validatorInfo);
    case (2 <= $argc):
        $breakChainOnFailure = array_shift($validatorInfo);
    case (3 <= $argc):
        $options = array_shift($validatorInfo);
    default:
        $this->addValidator($validator, $breakChainOnFailure, $options);
        break;
}?>
After some googling it looks like a reasonably common practice in languages where you can switch whatever you want, but it still makes me feel dirty.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Geekner posted:

Do VB switch-cases fall-through? If so, there are no words to describe the horror.

No, they don't.

Adbot
ADBOT LOVES YOU

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
FUCKIN' AJAX, MOTHERFUCKERS! :science:
code:
row = table.insertRow(-1);
cell = row.insertCell(-1);
cell.colSpan = 2;
div = document.createElement('div');
div.appendChild(document.createElement('br'));
cell.appendChild(div);
Much better (and clearer and easier to maintain) than, say
code:
html += '<tr><td colspan="2"><div><br></div></td></tr>';
This table(layout) has 8 rows of UI plus those empty rows. The non-empty rows are of course even more horrible. A function generates this table. There are several similar functions. Imagine the size of that javascript file.

Wheany posted:

This codebase is pretty :krad:

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