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
pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

bitreaper posted:

... Passport, , L2F, ...

It's funny; I laughed at the error message, then noticed what I imagine is the error (quoted) one second later.

Why can't I do that with my own code...

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Found this in the PHP manual. It's like the guy knew he wanted some kind of conditional execution, but forgot about the "if" keyword.

code:
switch (TRUE)
{
 case ($phlen < 7):
   $ext = $ph;
   break;
 case ($phlen == 7):
   sscanf($ph, "%3s%4s", $pfx, $exc);
   break;
 case ($phlen > 7 AND $phlen < 10):
   sscanf($ph, "%3s%4s%s", $pfx, $exc, $ext);
   break;
 case ($phlen == 10):
   sscanf($ph, "%3s%3s%4s", $area, $pfx, $exc);
   break;
 case ($phlen == 11):
   sscanf($ph, "%1s%3s%3s%4s", $cty, $area, $pfx, $exc);
   break;
 case ($phlen > 11):
   sscanf($ph, "%1s%3s%3s%4s%s", $cty, $area, $pfx, $exc, $ext);
   break;
}

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Surge Strip posted:

code:
function Upercase(str : string) : string;
   var
   len : integer;
   count : integer;
   newstring : string;
   begin
   len := length(str);
   count := 0;
   while (count < len) do
      begin
      newstring[count] := str[count] - 32;
      count := count + 1;
      end;
   result := newstring;
   end;

Woah, OK, this example here takes the cake. Let me see if I can list the problems here:

1. A function that does the intended effect already existed.
2. The function name is purposely misspelled.
3. I've never written Delphi before, so correct me if I'm wrong, but newstring is going to be the old string's ASCII characters shifted down 32. So this fantastic reimplementation doesn't even do anything right. (Your newline is now ASCII -22! Or maybe even 234! :woop: )
4. This is a trivial function for someone a month into their first ever programming class with no prior experience. Yet someone got paid to write this.

This simply cannot be topped. This is maximum :psyduck:.

(Did I miss anything?)

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

MrMoo posted:

Return value seems to be undefined if string has length zero.

It won't simply return the empty string?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

king_kilr posted:

PHP?

code:
<?php
function foo() {
    return 2;
}

echo foo();
?>
code:
2
Keep guessing.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

noonches posted:

code:
<select ="prefix">
    <option value="<?=$_SESSION['prefix']?>"><?=$_SESSION['prefix']?></option>
    <option value="mr">mr</option>
    <option value="mrs">mrs</option>
    <option value="ms">ms</option>
    <option value="dr">dr</option>
</select>
So I guess rather than just adding "selected" with like a tiny piece of code, it's trying to add the option you had previously selected to the top so it defaults to the selected one.

It's not that bad, it's just irritatingly lazy.

That is pretty sad, especially since it'll have duplicates of whatever value's thrown in. However, what's this "tiny piece of code" you'd use to add "selected"? It's as long as that if I recall correctly.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

G-Dub posted:

Finally, when opening the site instead of just opening an HTML file you open an HTA file, which is apparently an HTML Application. Is this ever excusable?

Maybe it's doing some really cool fuckery that you can't do with non-application HTML.

I don't have a clue what such fuckery would look like, but who am I to say it doesn't exist.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
People seem to be arguing over fundamentally different definitions of "exception". If there was ever an overloaded term in the realm of coding, it's "exception". It means everything to everybody. Janin almost hit it: if you come into Python thinking "'exception' means non-Python definition x", it won't look right. Part of making your own language is deciding what "exception" means to you.

Wikipedia's definition of exception handling is something that is "designed to handle the occurrence of a condition that changes the normal flow of execution". That definition seems general enough to include the case where a generator/iterator/etc. can't continue executing normally because there's nothing left to generate/iterate/etceterate. Beyond that, it's up to the language.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ZorbaTHut posted:

I spend a lot of time in a C++ help channel and, from my experiences there, I've concluded that many people's brains simply freeze up when they see an error message. They see "error" and they just panic and stop thinking.

It used to be that people would come in and ask "what does (incredibly self-explanatory error) mean?" and I'd explain it. But I realized after a while that they didn't need me to explain it. They just need me to repeat it. More than a few times I've quite literally just copy-and-pasted the error message, without the word "error" at the front, and suddenly they understand it, without even realizing what I've done.

You know, that makes total sense. Lots of things only click when the context is changed. It seems that taking the information out of the context of "an error message" makes the problem much easier to solve.

quote:

I weep for humanity.

Oh, you were just being a dick. :(

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ShoulderDaemon posted:

:words:

You could've just said "some people don't read what they write" and saved yourself a lot of handwaving.

I think you even tried to say that somewhere in the middle there.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Beardless Woman posted:

code:
    #Just a holder place so i don't have to do reverse logic

Ah yes, that ancient coding blasphemy. Death to the not operator! All hail empty code blocks! Allah ackbar!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ehnus posted:

No, but "unless" certainly is.

What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"?

e: Come to think of it, isn't "if" redundant if you have goto? And "else" is sure overrated hey? I just jump right there. Surely we don't need for loops if we have while loops. Why have a break statement when you can just use a flag?

When does "arbitrary" cross into "quite helpful" for you? Especially if it boils down to the same instructions in the end.

pokeyman fucked around with this message at 19:03 on Apr 12, 2009

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Gazpacho posted:

I don't see the point of arguing whether Perl has redundant features. Larry Wall admits it and is proud of it.

Wasn't arguing about Perl redundancy, more that being pedantic about redundancy in coding leaves you with a tiny set of nonredundant operations and most likely unreadable code. But I'm done.

Regarding conditional goto: I meant to say branch, sorry. Branch/if and goto/break. Y'all got my point: higher-level constructs like if boil down to low-level constructs like branch, so they're redundant, but surely we find value in them, etc. etc. I don't think Beardless Woman found value in an empty code block, as he expected a not or an unless, so he posted it here. That's all.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ehnus posted:

Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.

code:
if !something_false do hurf; // 1

if not something_false do durf; // 2

unless something_false do hurfdedurf; // 3
Numbers two and three are clearer to me than number one (goddamn exclamation point is easy to miss, especially with parentheses thrown in), and the third reads ever so slightly more naturally to me than the second. Maybe you save a fraction of a second by not typing an extra, count them, 3 characters (in statement one); if that's your goal, good for you? (Personally, having to twist up then back to hit the 1 key slows me down as much as typing 'ess'.) At worst, there is no difference when I read the code, so what do I care? Do you honestly find yourself struggling to read any of the above three statements?

Calling something "redundant" doesn't imply it's a worthless feature; we've covered this. Stop using that as a crutch, and just explain your opinion.

pokeyman fucked around with this message at 23:10 on Apr 12, 2009

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

That Turkey Story posted:

Both statements have undefined behavior unless those are overloaded operators. Post or pre-increment doesn't matter, assuming C or C++, that is.

I get why post/pre doesn't matter, but why is the overall behaviour undefined? To my (admittedly untrained) eyes, assuming i and j are numbers, that line increments i by one then ensures it didn't just grow larger than j, wrapping around to 0 if so. Did I get that wrong?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

rjmccall posted:

With a few exceptions, the order of execution of side-effects within expressions is not specified in C/C++, so it is permitted for the increment to logically happen after the assignment. The major exceptions are the comma operator (left before right), the ternary operator (condition before chosen expression), and call-like operations (function and arguments (in any order) before call). (n.b. this list is not guaranteed to be exhaustive)

Thanks for the explanation.

Vanadium posted:

no this is not "who knows what the value of i is going to be afterwards", this is literally undefined behaviour

you do not have to argue why it is because it just says in the standard not to do that poo poo

Calm down champ, nobody's trying to stir up poo poo but you. "Literally undefined behaviour" and "not specified in C/C++" mean the same thing to me, and either way I got the point: the result of this expression is not defined, and thus a coding horror. I didn't know it was undefined in C/C++ so I didn't see why it was a horror. Following along? Great.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

tef posted:

this for new cobol title

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Pooball posted:

I don't see how this could be done any better.

Factor out the isset check
code:
if ($keyword = get_if_isset($attribs['__select_keyword'])) 
{
    $query = "SELECT $keyword * FROM " . $db_name;
}
and write get_if_isset once, instead of abusing the poo poo out of the ternary operator?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Zombywuf posted:

Cue coding standard that require prefixing creatively naming similar functions in order for Eclipse to group them correctly.

Much more fun.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Sebbe posted:

I think I'll start using roman numerals

code:
#define I 1
...
#define LVI 56
...
#define DCCXXXV 735
...

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Any attempt to start the PHP derail should be bannable throughout CoC.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
What does what you said have anything to with what you quoted?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

yaoi prophet posted:

What exactly does '3rd-level damage' mean?

When the epidermis is lost with damage to the subcutaneous tissue?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

floWenoL posted:

God forbid anyone point out coding horrors in the coding horror thread!

He was pointing out a human horror, that goes in the other thread. The one on page twelve or whatever.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Ryouga Inverse posted:

this works until:

I can't figure out a way to make yes take a line feed. Just strips slashes here on OS X.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

tef posted:

yes newline

Man I'm dumb. I'll file that away. It'll come in useful one day.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ton1c posted:

You know it's funny, a good number of people reading this thread and that reddit thread would probably be guilty of a number of things in this thread. Programming should be more like music, where you compete against yourself rather than bash those who suck, but then nothing would get done.

And nobody should ever listen to each others music, we'll all just whittle our own instruments and play holed up in our rooms and never speak of it again. Most importantly, we'll never critique one another's music. This will guarantee all but one of us are stuck at the beginner level, and we'll all be happy.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
From the helpful comments department:

code:
#include <assert.h>                                       // assert
#include <map>                                            // multimap container
#include <string>                                         // string class
#include <iostream>                                       // C++ I/O
edit: Wow, I've never seen this one before. Right-aligned asserts with left-aligned code!

code:
void action() {
	                                                assert( !thing.empty() );
	                      assert( (*thing.begin()).first == thinger->now() );
	Foo f = (*thing.begin()).second;
	// everything else is left-aligned
}

pokeyman fucked around with this message at 00:25 on Nov 27, 2009

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

A A 2 3 5 8 K posted:

http://search.cpan.org/~bshade/Array-PAT-2.0.0/PAT.pm

Array::PAT - PHP Array Tools - Perl extension for array functions that are built into PHP.

Array::PAT posted:

Just as The Beatles say:

This applies to all functions, unless otherwise noted. If you use pass by value, you will recieve a value back, but if you pass a reference to a hash or value, you will receive a reference back. This is to support backwards compatability, it might be removed in later releases.

Forgot about that humdinger. That's from the Yellow Submarine lyrics right?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

pseudorandom name posted:

You see any MUMPS source.

It's named after a goddamn disease.

Or is the disease named after it...

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
http://www.phpfreaks.com/forums/index.php/topic,240487.0.html

guy with problem posted:

In an attempt to automatically hide my email from spam bots, I have been working on a script that turns all email [addresses?] on a page into ASCII, however I am having trouble with one little bit of code.

phpfreaks superstar posted:

I like to give each user that can receive e-mail a unique id that pertains to the user e-mail address, then on the back end I run the mail algorythim.

phpfreaks superstar posted:

There is a built in option for mail to be sent as html, not other things.

phpfreaks superstar posted:

Are you talking about having a captcha that is required before sending the e-mail to someone, otherwise it runs a loop?

I swear this guy's a bot running a rudimentary search engine.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Perl-compatible regular expressions.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
What do objects and that switch statement have in common? Or why would that shut them up in that debate?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Oh, ok. Carry on with the unmasking of the incompetent coworkers!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
From the Ask General Programming Questions thread:

Nippashish posted:

In Java | and & are the non-short-circuiting versions of || and &&.

*is given counterexample of 1 && 2 and 1 & 2*

Nippashish posted:

They're also bitwise operators when the operands are integral types. Maybe you should try them with boolean operands.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
When I suggest making a new function to a certain non-programmer taking an intro CS course it's always met with groans. This despite agreeing later that the added function makes things clearer and easier. Maybe it's the mental context switch needed, and I just don't notice it after so much practice.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Monkeyseesaw posted:

This is largely moot anyway. He's not writing unit tests for a drat school assignment.

If I'd known about unit tests it would've made some assignments sooooooo much easier...

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
That's why there isn't a fight in Python: there's a style guide. Like all style guides, it provides rules that should be followed unless you have an excellent reason not to.

Given this, why is "following a standard blindly" a horror? If you can't be bothered to think about whether you should break a rule, the least confusing thing to do is follow the rule.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Rocko Bonaparte posted:

I was trying to figure out what you had cooking with the acronym too. I remember in college they rammed something down our throats like that where we could only return right at the end of things. What I thought particular worse was they were also anal about breaking out of loops. So you'd have to throw your terminal conditions in the loop construct and often deal with signal variables of some kind.

One of my profs went violently in the other direction, taking off style points unless every loop was an infinite loop where you break out of it somewhere (maybe multiple places) in the loop body. It was actually kinda useful because it can be more readable, and awesome because signal variables could be eliminated (their use was an even more egregious style violation).

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Hammerite posted:

I think this could be defensible, depending on what exactly it's being used to do. Similar to how while (true) {...} can be a useful control structure.

You might've had a point with do { .. } while(0), but you missed your chance.

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