|
Foxfire_ posted:
I'm tempted to put this in a PR and see if anyone notices.
|
# ? May 22, 2020 18:48 |
|
|
# ? Jun 5, 2024 06:27 |
|
Foxfire_ posted:
Honestly, this is the perfect comment for a file header, for nearly any file. Just gotta have ASCII art of the dude vomiting.
|
# ? May 22, 2020 23:32 |
|
Dumb Lowtax posted:
I'm the always true tuition_defined
|
# ? May 22, 2020 23:58 |
|
ratbert90 posted:I'm the always true tuition_defined I know modern compilers usually warn about this, but I've done quite a bit of C89 programming for retro computers lately and have gotten into the habit of code:
code:
|
# ? May 23, 2020 10:25 |
|
Yesss, using the Yoda condition to contain the power of an unintended side effect is so edit: vvv check the name of the smiley Beef fucked around with this message at 11:20 on May 23, 2020 |
# ? May 23, 2020 11:06 |
|
Beef posted:Yesss, using the Yoda condition to contain the power of an unintended side effect is so TBF I don't use it in modern work. I just use it when I LARP old programming.
|
# ? May 23, 2020 11:18 |
|
brb finding a language where "true = tuition_defined" redefines the constant "true"
|
# ? May 23, 2020 11:19 |
|
code:
|
# ? May 23, 2020 11:21 |
|
Qwertycoatl posted:brb finding a language where "true = tuition_defined" redefines the constant "true" Python EDIT: oh they seem to have changed this in Python 3, I had not tried such Stupid Python Tricks in Python 3. Ghost of Reagan Past fucked around with this message at 12:35 on May 23, 2020 |
# ? May 23, 2020 12:16 |
Qwertycoatl posted:brb finding a language where "true = tuition_defined" redefines the constant "true" I remember once looking at some compiled Basic for DOS where you could pass a numeric constant (like 4) by reference to a function, and have the function modify the reference, and that would cause the constant to change value everywhere in the program. So you could make instances of the numeric literal 4 all have value 5.
|
|
# ? May 23, 2020 12:47 |
|
lobsterminator posted:I know modern compilers usually warn about this, but I've done quite a bit of C89 programming for retro computers lately and have gotten into the habit of I don’t think “if (true == tuition_defined)” is any less terrible than “if (tuition_defined == true)” would have been. its even harder to accidentally assign a value if you don’t use an unnecessary explicit comparison. If anything, yoda comparisons are a code smell, since they tell you that the author is careless and only god can help you if they ever compare two variables
|
# ? May 23, 2020 15:02 |
|
I put "use strict" in my js so I can't typo a variable name and have the language think I meant to declare a new variable. I don't think that means you can't trust me to use variables.
|
# ? May 23, 2020 15:10 |
|
Yoda comparisons are a code smell because they indicate that there's no linting going on.
|
# ? May 23, 2020 15:10 |
|
What they should have done is standardized something if(expr; boolean valued const expr), with if(; boolean valued const expr) the mandatory form when you're not doing any assignments or changing things, to make it really hard for you to shoot yourself in the foot like this.
|
# ? May 23, 2020 15:50 |
|
Doom Mathematic posted:Yoda comparisons are a code smell because they indicate that there's no linting going on. This is the real answer. Your IDE should be warning you "hey chief, this is an assignment, you sure you want to do that?"
|
# ? May 24, 2020 02:26 |
|
But I miss those because of all the other warnings
|
# ? May 24, 2020 05:30 |
|
https://twitter.com/krisnova/status/1264415917116502025
|
# ? May 24, 2020 06:11 |
|
Volmarias posted:This is the real answer. Your IDE should be warning you "hey chief, this is an assignment, you sure you want to do that?" With sensible warning settings modern C++ compilers do that. IDE support is great, but that shouldn't ever see a binary anyway.
|
# ? May 24, 2020 06:56 |
|
Foxfire_ posted:
Well, this is fun but is not the spirit I want for the code where I work. This marquee would be okay for fully cursed code. Anyway this marquee is glorious and I would order a militar parade in his honor if I where president of the united states.
|
# ? May 24, 2020 07:15 |
|
Volmarias posted:This is the real answer. Your IDE should be warning you "hey chief, this is an assignment, you sure you want to do that?" A decent language would have just made using assigning to existing variables inside if conditions invalid code, so you could still do "if (auto blah = bleh)" but not "if (blah = bleh)". The former's useful, while the later is nearly always going to be an accidental mistake. Maybe if epochs gain traction this could become a thing, it doesn't really change the meaning of the code, just makes one specific case invalid so there's no issue with silent behaviour changes. e: Oops, thought this was the C++ thread, point still stands about not supporting assignment inside ifs unless assigning to a new variable. Falcorum fucked around with this message at 10:31 on May 24, 2020 |
# ? May 24, 2020 10:27 |
|
more falafel please posted:With sensible warning settings modern C++ compilers do that. IDE support is great, but that shouldn't ever see a binary anyway. Look at this guy who looks at the warnings instead letting all 10,000 scroll past
|
# ? May 24, 2020 15:31 |
|
Falcorum posted:A decent language would have just made using assigning to existing variables inside if conditions invalid code, so you could still do "if (auto blah = bleh)" but not "if (blah = bleh)". The former's useful, while the later is nearly always going to be an accidental mistake. sometimes you want to do this if(a =foo()) { call(a); bar(a); } do something with the result of foo, but only if is true I don't know other people, but the times I mistake a == for a = are really small, like only once in a year
|
# ? May 24, 2020 21:40 |
|
Tei posted:sometimes you want to do this It's such an easy way to screw up that it's almost irresponsible to not habitually do code:
code:
|
# ? May 24, 2020 22:10 |
|
Tei posted:sometimes you want to do this In C++17 you can separate the assignment from the test: code:
|
# ? May 24, 2020 23:13 |
|
MutantBlue posted:In C++17 you can separate the assignment from the test: How antiquated, modern developers write 'if err, thing; err != nil {' now
|
# ? May 25, 2020 01:05 |
|
code:
|
# ? May 25, 2020 06:01 |
|
dougdrums posted:
I see code:
|
# ? May 25, 2020 07:22 |
|
Biowarfare posted:I see Minified JS or source? Minifiers do some pretty illegible things. I wouldn't use that idiom in source except under some fairly specific conditions.
|
# ? May 25, 2020 13:52 |
|
I like doing it only for checking if a flag is set iecode:
Another gem for that: code:
|
# ? May 25, 2020 14:13 |
|
you can always write with less letters, but if you code become hard to read is time to stop we don't want to repeat Perl
|
# ? May 25, 2020 14:15 |
|
Doom Mathematic posted:Minified JS or source? Minifiers do some pretty illegible things. I wouldn't use that idiom in source except under some fairly specific conditions. I got bit by this earlier this year. code:
Unfortunately, that makes: code:
The problem becomes when minifiers apply de morgan's law (e.g. !(b && u) == !b || !u) I did have a logic error, but stepping through the minified code caused a lot of anxiety because the minifier applied de morgan's laws and actually exposed the error, but it was transformed in such a way that I had to start thinking "oh poo poo, does this optimizer apply de morgan's law and apply short circuiting to runThisStuff() in a way that I expect?"
|
# ? May 25, 2020 15:14 |
|
i use && and || as one-line control flow all the time in JS and bash, though i'd prefer having Ruby's version of it:code:
|
# ? May 25, 2020 17:36 |
|
Yeah I love having to read a line of code all the way to the end to figure out if it's even going to execute or if it's just going to yell 'not!!!' like Borat.
|
# ? May 25, 2020 17:56 |
|
Taken from Perl which also has the inverse:code:
|
# ? May 25, 2020 17:56 |
|
Volte posted:Yeah I love having to read a line of code all the way to the end to figure out if it's even going to execute or if it's just going to yell 'not!!!' like Borat. ... && for me->poop_on();
|
# ? May 25, 2020 18:04 |
|
MrMoo posted:Taken from Perl which also has the inverse: Nope, only acceptable for the most metal of conditions, or die, which silently fulfills the darkest wishes of the computer toucher. It also makes skate or die valid Perl.
|
# ? May 25, 2020 18:25 |
|
Volmarias posted:It also makes skate or die valid Perl. Random paint splatters are valid Perl.
|
# ? May 25, 2020 18:33 |
|
Perl has a artistic license is for a reason
|
# ? May 25, 2020 18:37 |
|
Look, Perl's whole raison d'etre is to let lazy programmers be productive, and what better way to prototype than to just throw paint at the wall and see what sticks?
|
# ? May 25, 2020 18:51 |
|
|
# ? Jun 5, 2024 06:27 |
|
Volmarias posted:Look, Perl's whole raison d'etre is to let lazy programmers be productive, and what better way to prototype than to just throw paint at the wall and see what sticks? Yes, paint. That's definitely what they're using.
|
# ? May 25, 2020 18:53 |