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
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.

Zombywuf posted:

Also, why should it not be possible to call a member of a null object?
Because 99.9999999999999999999% of legitimate member functions will try to do something with what this points to.

Adbot
ADBOT LOVES YOU

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.

Entheogen posted:

what is so horrible on exiting when exception occurs? For some exceptions it makes sense, and you can print out what the message was before you exit anyways.
Because that example doesn't do anything with the exception(s) and manages to give less information than if the exception(s) had just been left uncaught.

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.
You're both missing the real problem. DestroyEvent() takes a CGameEvent* (or CGameEvent*&); it's not invalidating any iterators. So, that comment is ironic, because the remaining events won't be iterated. mEvents.begin() isn't going to change, so re-accessing or deleting that element that got destroyed on the first iteration will probably crash the program.

edit: What's an "lIterator" supposed to be, anyhow? Loser Iterator?

Mustach fucked around with this message at 21:17 on Jul 31, 2008

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.
Oh man, that would make that segment of code a lot worse.

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.
Either the headers date back to some ancient and barely-standard-conforming VC, were tool-generated, or were jerk-generated.

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.
Does the runtime overhead of creating a list and copying elements to it count as a coding horror?

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.

Volte posted:

No, because if the number of possibilities is small enough that you would otherwise list them in the code then the performance difference is negligible.
Maybe, but it's an unnecessary source of potential overhead for a negligible readability improvement.

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.
== and != are overloaded to do value comparison for Strings in C#.

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.
You say that like references are one of C++'s harder-to-understand constructs.

Lexical Unit posted:

For fucks sake this guy wrote nearly 300 kloc of C++ and he doesn't know what a reference is? gently caress me.
More evidence against putting much meaning behind line counts. When you code like the guy in BigRedDot's story, it's pretty easy to hit the high numbers.

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.

Anonymous Name posted:

Using pointers for output (&lines, &output) makes it more obvious. Plus it allows you to pass NULL if you don't care about a certain value,
code:
f(&p, NULL, &r);
Argh my program crashed because the function tried to dereference and write to NULL. Also which of those are output params; I think this function takes at least one pointer-to-const.

floWenol posted:

If they're not, one has to look up each function where said variable is used as a parameter. Lame.
Yeah that's real tough.

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.

floWenoL posted:

I don't know if you're being intentionally obtuse, but the idea is to use pointers (and not references) only for output parameters.
There are plenty of currently-existing functions in the world that take pointers as input parameters, and Anonymous Name already mentioned passing in NULL as a valid argument.

quote:

Oh, how cute, someone who has never done maintenance on a large code base.
Being able to search for "&v" over "v" is not the huge timesave you're making it out to be. Java has no "const"; any method can modify any object that's passed to it if the object's class has mutators. That hasn't stopped the creation of huge and functioning Java codebases, probably because they aren't structured so that "I don't know where this variable is being modified, time to search every source file" becomes possible.

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.

floWenoL posted:

Wrong-o. I'm saying that the writer of functions should be documenting whether their functions handle NULL or not.
You liar:

floWenol posted:

Lexical Unit posted:

So what is the person who's reading the code going to get out of reading it if they don't know what any of the functions do? :raise:
Whatever can be gleaned from the function name, comments, and parameter names. If pointers for output params were used consistently, a simple search suffices to find out where a variable can be modified in a called function. If they're not, one has to look up each function where said variable is used as a parameter. Lame.

The person who wrote the code may be completely familiar with the function, but maybe not the person reading the code later.
If that's what you really meant, then I'm going to drop it, too. My biggest problem was with the idea that pointer-as-out was some kind of replacement for reading function documentation/asking a coworker; the rest just spun off of that and is apparently well-beaten horse.

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.
Use Type.GetField(), don't use Type.GetFields() and loop through (possibly) all 5500 of them.

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.
code:
ifpf67_ptr = (Ifpf_0067 *) ((void *) MH_ADDR_ST(
  ((Msg_hd *) &(((FP_msghdr *)(((void *)&((Fp_mcom_bfhd *)
  (&((byte *)(p_msdes)->heap)[(((p_msdes)->mstb[(0)]).ofbf)]))[1]))))[1])));
I need to know what MH_ADDR_ST expands to; I want to see the whole thing, and then see what it simplifies to.

Mustach fucked around with this message at 18:01 on Sep 11, 2008

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.
It looks like what I posted above you. All on one line, of course.

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.
Whoever wrote MH_ADDR_ST() is an rear end in a top hat for writing a macro that re-evaluates its argument three times. "Who needs functions or temporary variables? I know what I'm doing! It's a macro, it'll be efficient no matter what!"

Beaten, but whatever I figured it out without having a clue so I'm posting this diagram:
code:
--------------
|Fp_mcom_bfhd|
--------------
| FP_msghdr  |
--------------
|   Msg_hd   |
--------------
|            |
| /* st_off  |
| bytes */   |
|            |
-------------|
| Ifpf_0067  |
-------------|

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.

tef posted:

And signals are part of posix, not C :3: last time I checked.
C gaurantees signal(), raise(), and SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM. However, "The complete set of signals, their semantics, and their default handling is implementation-defined…"

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.
Don't look a gift horse in the mouth, I guess.

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.
You can't subclass java.lang.String.

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.
Sorry, I was talking about Java, not GNU Gava or whatever

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.

floWenoL posted:

I also enjoy !(x ^ y), which is equivalent to x == y.
Reminds me of a thread from a few years ago in which somebody called '!=' bloated.

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.
High as gently caress

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.
Explicitly nulling references is worthless 98% of the time, yet it seems to be a pretty popular M.O.

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.
It's just a for-loop followed by a while-loop. It's hosed-up in other ways, but it's not a special syntax or anything like that.

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.
Another feather in PHP's security hat

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.

rjmccall posted:

I'm curious if there's a difference between DynamicArray::Size() and DynamicArray::GetNumb().
GetNumb() is what you do when you have to work with code like that.

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.
And now we flame each other over currying.

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.
Must be an embedded whitespace script.

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.

Avenging Dentist posted:

Given that people make functions called doit or run in Java, yes.
public interface Doable{

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.
code:
public interface Thing{
  void doThat();
  void okDoTheRealThing();
  void helperMethod();
  void helperMethodForOkDoTheRealThing();
}

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.

rjmccall posted:

really silly workarounds like Swing's J prefix on every single class in the library.
Correction: most classes in the library. Which makes it even worse because it's inconsistent!

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.
I don't buy type erasure as the excuse for not being able to say new T[n]. That expression doesn't even need any type information since the elements are all initialized to null and no other "T" methods are used.

It's just another reason to not use Java arrays for anything but varargs.

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, I should've thought of that since I enjoy bitching about array covariance and the runtime checks associated with 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.
It returns size_t.

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.

rjmccall posted:

(b) the program and someone can't happen again or
What was this supposed to say?

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.
Nope, sorry, don't wanna break backwards-compatibility with all of the high-quality software that depends on barewords

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.
code:
HashSet<MutableInt>
edit: Actually, it may have been a HashMap<MutableInt,String>

Mustach fucked around with this message at 22:31 on Jul 7, 2009

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.
This is the only good Perl program:
code:
#!/usr/bin/perl
$_='
         $q ="\                   47"; wh
        ile                           ($ ;=
      $z                +=              .5 ){
    %c=           $r=0;$/ ="";whi         le(2
   0+          $z>($;+=.05)){$c{int$       _+ 2
  6+         2*($              r+= .0       2) *
 s          in$                   ;}{1       -$_
+1         0+           int        $r*c       o s
$         ;}         =1for(0.       .1)        }$
t        =r         ever se;$        /.        =`
c        le        ar     `.         "         #!
/        usr       /bi             n/         pe
rl       \n\       $_ =$q        \n"          ;
fo        r$y        (1..20){$c{$_}          {
$ y       }? $         /.=chop$t            :
 ($/        . ="                          \4
 0")         for(0.                    .53)          ;
   $/.        ="\n"}pri            nt"$/$          q;
   s; ".         chr(9 2)."s;;g;eval\n           "}

';s;\s;;g;eval

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.

Adbot
ADBOT LOVES YOU

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.
Gradian: The GNU radian

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