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
Kallikrates
Jul 7, 2002
Pro Lurker
Copy pasting and random changing of code to make the log statements look right

Adbot
ADBOT LOVES YOU

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

What does that do? Seems like it would throw a runtime exception.

Kallikrates
Jul 7, 2002
Pro Lurker
If its javascript (betting it is) and foo is a String, It's the same as doing:
code:
[foo]
//""[0] -> undefined
//foo.split(undefined) just returns the left side in the array since split always returns an array?

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Dr. Stab posted:

What does that do? Seems like it would throw a runtime exception.
Assuming null-terminated strings, it's a less-readable version of foo.split('\0')

But you can't have multiple nulls in a null-terminated string so :confused:

Absurd Alhazred
Mar 27, 2010

by Athanatos


(source)

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
That's even less coherent than the usual xkcd. Is Randall developing a brain tumor or something? Maybe Charles Boyce is ghostwriting for him?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Internet Janitor posted:

That's even less coherent than the usual xkcd. Is Randall developing a brain tumor or something? Maybe Charles Boyce is ghostwriting for him?

I dunno, the creeping horror when I tried to read the code was pretty good. Not his best work, certainly, but I got my $0.00 out of it.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Internet Janitor posted:

That's even less coherent than the usual xkcd. Is Randall developing a brain tumor or something? Maybe Charles Boyce is ghostwriting for him?

He's been parroting in-jokes from his IRC channel for years.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

My guess after reading the tooltip on his website is he used content-aware fill on a code screenshot and phoned in that day's comic

Linear Zoetrope
Nov 28, 2011

A hero must cook

quote:

Prefer the least indented scope possible.

BAD:
code:
if(x == 0) {
    for(int i = 0; i < 20; i++) {

     }
}
GOOD:
code:
for(int  i = 0; i < 20 && x == 0; i++) {

}

xzzy
Mar 5, 2009

Yeah, who needs legibility when you can save two presses of the enter key!

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

Yes it's always better to jam as much logic as possible into one line. This makes it more legible since indentation is bad.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I would replace that code with:

code:
It has the same effect.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

xzzy posted:

Yeah, who needs legibility when you can save two presses of the enter key!

The lines are only equivalent in function if x is never changed within the for loop, so the code snippets are not equivalent.

qntm
Jun 17, 2009

Dr. Stab posted:

Yes it's always better to jam as much logic as possible into one line. This makes it more legible since indentation is bad.

I blame K&R.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

PT6A posted:

The lines are only equivalent in function if x is never changed within the for loop, so the code snippets are not equivalent.

You're right. I fixed it.

code:
for(int i = 20 * !!x; i < 20; i++) {

}

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

NihilCredo posted:

You're right. I fixed it.

code:
for(int i = 20 * !!x; i < 20; i++) {

}

Ahem:

code:
for (int i = (x==0)?x:20; i < 20; i++) {

}
More ternary is more better!

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
code:
for (int i = (x==0)?x:20; (i < 20) ? true : false; i++) {

}
Well I guess it's back to this now.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

IT BEGINS posted:

code:
for (int i = (x==0)?x:20; (i < 20) ? true : false; i++) {

}
Well I guess it's back to this now.

code:
#define ZERO 0
#define LIMIT 20
#define CONTINUE_LOOP true
#define DO_NOT_CONTINUE_LOOP false

for (int i = (x==ZERO)?x:LIMIT; (i < LIMIT) ? CONTINUE_LOOP : DO_NOT_CONTINUE_LOOP; i++) {

}

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

No, sorry, the 20 * !!x is sublime in its compact insanity.

I have intentionally and thoughtfully written the sequence * !! in code you have probably run.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

I think you mean
code:
int iLoopIterator

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal
Whoa, let's not take this too far now. Even the most heretical programmer isn't going to gently caress around with conventions that have been handed down from our forefathers who toiled in the FORTRAN mines all those decades ago. It's i, j and k.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

PT6A posted:

code:
#define ITERATOR i
#define ZERO 0
#define LIMIT 20
#define CONTINUE_LOOP true
#define DO_NOT_CONTINUE_LOOP false

for (int ITERATOR = (x==ZERO)?x:LIMIT; (ITERATOR < LIMIT) ? CONTINUE_LOOP : DO_NOT_CONTINUE_LOOP; ITERATOR++) {

}

'i' is a magic name.

FamDav
Mar 29, 2008

Subjunctive posted:

No, sorry, the 20 * !!x is sublime in its compact insanity.

I have intentionally and thoughtfully written the sequence * !! in code you have probably run.

JavaScript or C

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

FamDav posted:

JavaScript or C

:golfclap:

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

FamDav posted:

JavaScript or C

Yep.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

PT6A posted:

Welp, apparently I'm the coding horror.

Don't worry, plenty of reasons to use layout-only views. It's not "inelegant" if you think of it as defining variables in a program written in autolayout constraints. It would be better if autolayout had actual variables but, eh. You do what you gotta do

Subjunctive posted:

No, sorry, the 20 * !!x is sublime in its compact insanity.

I have intentionally and thoughtfully written the sequence * !! in code you have probably run.

Once you learn about !!, it's hard to justify not using it

Soricidus
Oct 21, 2010
freedom-hating statist shill
!! and --> are the two compound operators I use regularly. They're both good imo.

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Soricidus posted:

!! and --> are the two compound operators I use regularly. They're both good imo.

What does that second one do?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

KernelSlanders posted:

What does that second one do?

code:

while (x-- > 0) { }

code:

while (x --> 0) { }

Soricidus
Oct 21, 2010
freedom-hating statist shill

KernelSlanders posted:

What does that second one do?

code:
int touch_butts(butt_t* butts, size_t butt_count)
{
    while (butt_count --> 0) {
        touch(*butts++);
    }
}

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Subjunctive posted:

code:
while (x --> 0) { }

Yup, that's pretty horrible.

Absurd Alhazred
Mar 27, 2010

by Athanatos

KernelSlanders posted:

Yup, that's pretty horrible.

If there were a God, that would simply not compile. :dawkins101:

Soricidus
Oct 21, 2010
freedom-hating statist shill
Actually, it's good and cool and I use it without irony in production code.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Honestly, since installing Visual Studio 2015 I can't live without the tadpole operator.

quiggy
Aug 7, 2010

[in Russian] Oof.


Absurd Alhazred posted:

If there were a God, that would simply not compile. :dawkins101:

I'm sorry would you prefer that C/C++ had :siren: SYNTACTIC WHITESPACE :siren:

john donne
Apr 10, 2016

All suitors of all sorts themselves enthral;

So on his back lies this whale wantoning,

And in his gulf-like throat, sucks everything

That passeth near.

KernelSlanders posted:

Yup, that's pretty horrible.

It's actually extremely cool, and good.

Absurd Alhazred
Mar 27, 2010

by Athanatos

quiggy posted:

I'm sorry would you prefer that C/C++ had :siren: SYNTACTIC WHITESPACE :siren:

Honestly, I think postfix ++/-- should be depreciated. It was a terrible idea when first introduced in C and has never become a better idea since.

nielsm
Jun 1, 2009



quiggy posted:

I'm sorry would you prefer that C/C++ had :siren: SYNTACTIC WHITESPACE :siren:

Remember when vector<pair<int,int>> was bad and vector<pair<int,int> > was fine?

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015

nielsm posted:

Remember when vector<pair<int,int>> was bad and vector<pair<int,int> > was fine?

Yes. Happily at the time I worked on code that only had to compile under MSVC and it had the first form as an extension. :v:

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