Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Typedef considered harmful?

Name: Anonymous 2011-08-21 14:58

http://www.45mercystreet.com/computing/typedefs.html
I've read this guy's arguments and I'm still not convinced. Typedefs are incredibly useful. Say I'm implementing a tree to store ints but later I want to reuse it to store char*s if I don't use typedef I'm going to need to change every single instance that the int is used. If I had used a typedef I could have defined each node of the tree to contain a key_t and just change the type of key_t in one line. How is this code obfuscation?

So are typedefs harmful or not in your EXPERT opinion?

Name: Anonymous 2011-08-21 19:00

>>6
Just overload son.

#include <ooc/ooc.h>
#include <ooc/io/io.h>

void polymorphic f(int n) {
  printf("%d is a motherfucking int!\n",
         n);
}

void polymorphic f(double x) {
  printf("%f is a motherfucking double!\n",
         x);
}

int main(void) {
  f(1);
  f(1.0);

  return 0;
}


In before some autistic person cries over this not being in the standard, you made bro?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List