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

Pages: 1-

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 15:01

I only ever use typedefs in order to remove the struct keyword or for types that are completely abstracted behind an API, so I guess I'm not concerned.

Name: Anonymous 2011-08-21 15:08

Typdefs are mostly used to make structs opaque to the user of an API. This helps to decouple the implementation from the interface what is always an good idea (outside of Data Driven Programming).

That guy doesn't know shit about programing.




<frameset>


Nor about HTML.

Name: Anonymous 2011-08-21 16:14

>>1
You're going to have to dramatically improve your critical sense if you want to survive on the Internet...

Name: Anonymous 2011-08-21 17:13

Typedefs are useful if they are properly used.
This is the tl;dr of it all. Don't use typedefs if what you're going to do with the extra type is more than passing them around.

Name: Anonymous 2011-08-21 17:31

Introducing pointless typedefs like PDWORD and mystruct_t absolutely is code obfuscation.

Using typedefs where you would use templates in C++ is stupid because a typedef can only mean one thing. What if I want a tree of char * and a tree of int? Using #define is better, because you can prefix the function names and use both trees at the same time. But the best is to use the include/linux/list.h technique and don't use a tree containing foos, but foos that contain trees.

Documentation/CodingStyle chapter 5 has some more advice.

Name: Anonymous 2011-08-21 17:42

Fuck that, I'm not typing struct every time. Also, *_t is fucking retarded.

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?

Name: Anonymous 2011-08-21 19:01

I stopped having standards for C++ ages ago. It's like having standards for your shits.

Name: Anonymous 2011-08-21 20:06

>>8
That's not polymorphism, that's parameter overloading.

Name: Anonymous 2011-08-21 20:18

>>10

Polymorphic functions come from functional programming (e.g. Haskell) which is like parameter overloading.

Name: i_have_a_raging_boner !!kCq+A64Losi56ze 2011-08-21 20:26

>>11
Are you really this god damn stupid? Or are you just trolling?

Name: Anonymous 2011-08-21 20:49

>>12

Are you really this god damn stupid? Or are you just trolling?

Name: Anonymous 2011-08-21 21:05

>>13
I'm not the retard that made the following statement:

Polymorphic functions come from functional programming (e.g. Haskell) which is like parameter overloading.


Cripes, I don't think even your second your computer science student at a school like CSU Hawyard would make such an idiotic statement. Presumably, unlike you, they know and appreciate the difference between the two.

You've once again demonstrated that you don't have the mental capacity to do computer programmer. Now go help another customer you mental midget. Or if tonight is your night off, do something that is a tad bit easier. Like watching TV.

Name: i_have_a_raging_boner !!kCq+A64Losi56ze 2011-08-21 21:07

>>13
BTW, I don't hire dumbasses like you for *any* kind of actual programming work at my firm. Maybe, just maybe, if I was in a good mood, and felt sorry for you, I'd give you a job that involved answering customers technical problems over the phone.

Name: not >>13 2011-08-21 21:47

>>15
U so cool.

Name: Anonymous 2011-08-21 23:16

>>15
lol big mr NEET want's to hire people

Name: Anonymous 2011-08-21 23:24

Though he might have a good point about how typedefs are used in C. For example, size_t. You always have to remember that size_t is an int (or long)  because it's being compared against ints all the time.

Name: Anonymous 2011-08-21 23:32

>>14-15
i fucking hate you; I want Xarn back and this guy dead, right this instant!

Name: Anonymous 2011-08-22 0:51

Overloading considered hardmful
Pointer casting considered harmful
Changing consts considered harmful
Water considered harmful
Living considered harmful to health

Name: Anonymous 2011-08-22 0:52

>>15

my firm

The Semen Ingestion Corporation

Name: Anonymous 2011-08-22 1:12

>>21
are they unionized?

Name: Anonymous 2011-08-22 7:56

"Considered Harmful" Essays are considered harmful.
http://meyerweb.com/eric/comment/chech.html

Name: Anonymous 2011-08-22 11:17

>>23
No, they're just dumb.

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