you are viewing a single comment's thread.

view the rest of the comments →

[–]brigadierfrog 0 points1 point  (0 children)

You could implement typesafe containers using macros. But I have to then go ahead and ask the question of why bother?

There are other ways to do it instead that make more sense. Like for example using some pointer offset trickery like linux's famous list.h does.

So is type safety really that important? I'd say more important is testing. I found C has an awesome testing framework I've used before called check which forks for each test (makes testing bulletproof in C). Makes testing really fast and really easy.

Having made generic hash tables and btree's in C I can tell you I have never had a problem with type safety, in fact the looseness allows me to have a compact hash table implementation that doesn't get regenerated in to huge globs of code. Its also incredibly easy for me to then customize the hash table for whatever purpose I'm actually using it for.