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
Dijkstracula
Mar 18, 2003

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

That piece of code is incredible. At first glance it only looks moderately silly, but the more I stare at it, the more hidden horrors reveal themselves, like the blossoming of an enormous carrion flower. :gonk:

Adbot
ADBOT LOVES YOU

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

sex offendin Link posted:

My favorite part is the extra call to refresh(3) which does literally nothing.

/* not implemented yet */

Sam.
Jan 1, 2009

"I thought we had something, Shepard. Something real."
:qq:

huge sesh posted:

I've always thought this one was real pretty
code:
not exp log srand xor s qq qx xor
s x x length uc ord and print chr
ord for qw q join use sub tied qx
xor eval xor print qq q q xor int
eval lc q m cos and print chr ord
for qw y abs ne open tied hex exp
ref y m xor scalar srand print qq
q q xor int eval lc qq y sqrt cos
and print chr ord for qw x printf
each return local x y or print qq
s s and eval q s undef or oct xor
time xor ref print chr int ord lc
foreach qw y hex alarm chdir kill
exec return y s gt sin sort split
code:
$_=            '!&@$          %)(*&^(;(?&&*>(   !&@$%         )(
<@.^(          ;(/)/          |)%-]';s/ //g;    1111;       tr
[!|/]          [ybm]                ;s[-]       [\n]     ;tr
[<)?]          [jeg]                ;s[>]       [,];    tr
[.*;]          [sna]                ;tr         [@][u];tr
[^$]           [t'];             tr[&%]         [or];   tr
[(][ ];s[\n]   [];chop       ;s[\\][];          print     ;#

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
That's awesome, did you do that yourself or use a program?

Sam.
Jan 1, 2009

"I thought we had something, Shepard. Something real."
:qq:

Triple Tech posted:

That's awesome, did you do that yourself or use a program?

A program would make less clumsy-looking letters.

Thibaw
Jul 21, 2009
I guess some of you know this already:

code:
int random(){
  return 2; //guaranteed random
  //fair dice roll!!
}
*edit*
stolen from xkcd.com
*edit*

Thibaw fucked around with this message at 23:21 on Jul 21, 2009

Scaevolus
Apr 16, 2007

xkcd jokes get more hilarious with each repost!!

ColdPie
Jun 9, 2006

Scaevolus posted:

xkcd jokes get more hilarious with each repost!!

hay guys i just registered have you heard this one?

there's 10 types of people, those who know binary and those wh :suicide:

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
It's his only post. Did he really register just to post a tired xkcd joke in here.

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
C'mon guys, plenty of people make lovely first posts, our job is to educate them so they don't end up like Victor or Chain Chomp

TheSpook
Aug 21, 2007
Spooky!

ColdPie posted:

there's 10 types of people, those who know binary and those wh :suicide:

I will educate all of my liberal arts about base two, lest they remain ignorant and commit suicide.

Dijkstracula
Mar 18, 2003

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

so this xkcd is an internet comic strip, you say

Opinion Haver
Apr 9, 2007

xkcd is decent (when it's about programming or other nerd stuff) but people reposting it like it's new kills any humor

floWenoL
Oct 23, 2002

Veinor posted:

xkcd is decent (when it's about programming or other nerd stuff) but people reposting it like it's new kills any humor

I wonder if xkcd is lovely today...if only there were a website that would tell me.

Nigglypuff
Nov 9, 2006


BUY ME BONESTORM
OR
GO TO HELL

floWenoL posted:

I wonder if xkcd is lovely today...if only there were a website that would tell me.
*writes a meandering 25-page blog post on the topic*

No Safe Word
Feb 26, 2005

floWenoL posted:

I wonder if xkcd is lovely today...if only there were a website that would tell me.

http://hasthelargehadroncolliderdestroyedtheworldyet.com/

they actually do a "check", too

Trabisnikof
Dec 24, 2005

<!-- if the lhc actually destroys the earth & this page isn't yet updated
please email mike@frantic.org to receive a full refund -->

mynameisntneo
Sep 12, 2006
Mr. Anderson
The company I work for outsourced some iPhone code to a offshore engineering company. I just got access to it today to look for how they were hitting our APIs, and I find this kind of code sprinkled throughout:

code:
ABVariable *variableGetMeep1 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep2 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep3 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep4 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep5 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep6 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep7 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep8 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep9 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep10 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep11 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep12 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep13 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep14 = [[ABVariable new] autorelease];
ABVariable *variableGetMeep15 = [[ABVariable new] autorelease];

[one-by-one set two properties on each variable]

variables.variable = variableGetMeep1;
variables.variable = variableGetMeep2;
variables.variable = variableGetMeep3;
variables.variable = variableGetMeep4;
variables.variable = variableGetMeep5;
variables.variable = variableGetMeep6;
variables.variable = variableGetMeep7;
variables.variable = variableGetMeep8;
variables.variable = variableGetMeep9;
variables.variable = variableGetMeep10;
variables.variable = variableGetMeep11;
variables.variable = variableGetMeep12;
variables.variable = variableGetMeep13;
variables.variable = variableGetMeep14;
variables.variable = variableGetMeep15;

request.variables = variables;
What does that do? Well...

code:
[in ABVariables.m]

@synthesize variables;

- (void)setVariable:(ABVariable*)variable
{
    [variables addObject:variable];
}
:saddowns:

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe
code:
    bool empty() {
        bool temp = true;

        for(int i = 0; i < _listCount; i++) {
            if(temp is true && _count[i] == 0)
                temp = temp && true;
            //  awesome way to make temp = false if it was already false, and true if it wasnt?
            else temp = (temp && false) && (temp && true);
        }

        return temp;
    }
some people find basic logic way too difficult :downs:

baquerd
Jul 2, 2007

by FactsAreUseless

clockwork automaton posted:

code:
    bool empty() {
        bool temp = true;

        for(int i = 0; i < _listCount; i++) {
            if(temp is true && _count[i] == 0)
                temp = temp && true;
            //  awesome way to make temp = false if it was already false, and true if it wasnt?
            else temp = (temp && false) && (temp && true);
        }

        return temp;
    }
some people find basic logic way too difficult :downs:

:ughh:

Edit: basic logic is way too difficult

baquerd fucked around with this message at 06:36 on Jul 23, 2009

Goat Bastard
Oct 20, 2004

clockwork automaton posted:

code:
    bool empty() {
        bool temp = true;

        for(int i = 0; i < _listCount; i++) {
            if(temp is true && _count[i] == 0)
                temp = temp && true;
            //  awesome way to make temp = false if it was already false, and true if it wasnt?
            else temp = (temp && false) && (temp && true);
        }

        return temp;
    }
some people find basic logic way too difficult :downs:

:pwn: whaaaaat?

I mean there's logic, and then there's bad logic, and then there's flat out incorrect logic, and I think this manages to be something else again.


Edit: The more I stare at this the less sense it makes. I think might be some sort of art. You're some sort of lecturer or something and a student wrote this for an assignment, right? A student and not someone who got paid for this, this collection of words?

Goat Bastard fucked around with this message at 12:35 on Jul 23, 2009

newsomnuke
Feb 25, 2007

Goat Bastard posted:

I mean there's logic, and then there's bad logic, and then there's flat out incorrect logic, and I think this manages to be something else again.
Well the function does actually work! Which makes it even more boggling because his 'awesome way' comment is wrong, which implies that he wanted it to do something else, but made a mistake and got it right unintentionally.

Goat Bastard
Oct 20, 2004

ultra-inquisitor posted:

Well the function does actually work! Which makes it even more boggling because his 'awesome way' comment is wrong, which implies that he wanted it to do something else, but made a mistake and got it right unintentionally.

My god so it does, I was so caught up in the beauty of it that I totally missed that. That settles it, the man who wrote this is an artist.

huge sesh
Jun 9, 2008

clockwork automaton posted:

code:
    bool empty() {
        bool temp = true;

        for(int i = 0; i < _listCount; i++) {
            if(temp is true && _count[i] == 0)
                temp = temp && true;
            //  awesome way to make temp = false if it was already false, and true if it wasnt?
            else temp = (temp && false) && (temp && true);
        }

        return temp;
    }
some people find basic logic way too difficult :downs:

There's no way the guy who wrote this didn't know what it was doing.

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.
"Single Point of Return" rears it's twisted head again. It seems like people that subscribe to it always use convoluted logic.

RoadCrewWorker
Nov 19, 2007

camels aren't so great

Mustach posted:

"Single Point of Return" rears it's twisted head again. It seems like people that subscribe to it always use convoluted logic.
Hm, lets google this...

quote:

I also a big fan of single return functions and I do not give up. In order to combine a single return with early aborting I use the the following trick:
code:
do {
    if (b == null) { // abort
      break;
    }
     ... // do something useful
} while (false);

... // cleanup
Posted by: Mikhail at August 1, 2005 10:07 AM
Well, im convinced!

mr_jim
Oct 30, 2006

OUT OF THE DARK

RoadCrewWorker posted:

Hm, lets google this...

Well, im convinced!

Christ, that's terrible even for single-point-of-return advocates. Usually they'll stick with creating extraneous variables for return values. Abusing a loop statement to avoid using a return statement is just awful.

Steve French
Sep 8, 2003

mr_jim posted:

Christ, that's terrible even for single-point-of-return advocates. Usually they'll stick with creating extraneous variables for return values. Abusing a loop statement to avoid using a return statement is just awful.

Honestly I think he'd have been better off in that case just using a goto

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

mr_jim posted:

Christ, that's terrible even for single-point-of-return advocates. Usually they'll stick with creating extraneous variables for return values. Abusing a loop statement to avoid using a return statement is just awful.

Even if you subscribe to single point of return, that function doesn't make sense, a regular if-block would do.

mr_jim
Oct 30, 2006

OUT OF THE DARK

dwazegek posted:

Even if you subscribe to single point of return, that function doesn't make sense, a regular if-block would do.

That's what I was talking about, actually.

code:
int result = 0;
if (b == null) {
    ...
    result = ...;
} else {
    ...
    result = ...;
}

return result;
I think this is silly as well, but it's not as much of a horror as the "do { ... } while(false)" thing.

Lexical Unit
Sep 16, 2003

code:
ImageMap::ImageMap()
{
    memset (this, 0, sizeof (*this));
}
C++, non-POD data members.

Edit: wow http://bytes.com/groups/cpp/621474-setting-every-bit-all-members-class-0-a

This kind of shortcut had never even occurred to me...

Lexical Unit fucked around with this message at 21:15 on Jul 23, 2009

Lexical Unit
Sep 16, 2003

Haha, same file:
code:
#define SIN(x) (sin((x)*M_PI/180))
Note that SIN() is only ever called once in the file, and it's never #undefed.

BigRedDot
Mar 6, 2008

Lexical Unit posted:

Haha, same file:
code:
#define SIN(x) (sin((x)*M_PI/180))
Note that SIN() is only ever called once in the file, and it's never #undefed.

We both know this particular developer's sins can never be erased.

Dijkstracula
Mar 18, 2003

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

Lexical Unit posted:

Haha, same file:
code:
#define SIN(x) (sin((x)*M_PI/180))
Note that SIN() is only ever called once in the file, and it's never #undefed.
Well, given it's wrong, I should hope it's not used very often!

plushpuffin
Jan 10, 2003

Fratercula arctica

Nap Ghost

dwazegek posted:

Even if you subscribe to single point of return, that function doesn't make sense, a regular if-block would do.

I don't think so. His example is really simple, but if you were to expand it, you can see where the if block would break down.

code:
do {
	if (a == null) // abort
		break;

	... // do something #1

	if (b == null) // abort
		break;

	... // do something #2

	if (c == null) // abort
		break;

	... // do something #3     
} while (false);

... // cleanup

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
So, I'm sure some of you know that C++'s throw specifiers don't always work too well, even for the no-throw case, e.g. void my_func() throw() {}. Luckily, the C++ standards committee has decided to resolve this, but since it's fairly late in the standardization game, they're worried about adding any new keywords, so they're reusing some old ones:

code:
void my_func() do not throw while using this
{
    // ...
}

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"

Avenging Dentist posted:

So, I'm sure some of you know that C++'s throw specifiers don't always work too well, even for the no-throw case, e.g. void my_func() throw() {}. Luckily, the C++ standards committee has decided to resolve this, but since it's fairly late in the standardization game, they're worried about adding any new keywords, so they're reusing some old ones:

Obvious troll, the C++ standards committee would never change anything that works as poorly as exception specifiers.

Scaevolus
Apr 16, 2007

Dijkstracula posted:

Well, given it's wrong, I should hope it's not used very often!

What's wrong with it?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

What's wrong with it?

The sine function generally does not range from -0.0174532778 to 0.0174532778.

Adbot
ADBOT LOVES YOU

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

Scaevolus posted:

What's wrong with it?

Does k*sin(x) = sin(k*x) for you?

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