Top all-time · #7715
Rob's Programming Blog
Personal blog · robertgamble.netprogramming
Rob's Programming Blog is a personal blog at robertgamble.net about programming. Since 2013, 10 different Hacker News readers have linked it 10 times, most often “C11 – Generic Selections”. The last post was in 2016, but the archive is still widely read.
Too few sampled comments (7) to say how often HN recommends it.?
Why HN links it
HN commenters link this blog's post on C11 _Generic type-generic selections as a reference for generics in C. The comments cite it as a source rather than judging the writing.
Summarised by Claude from a sample of 7 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Various Musings about Software Development and Technology
Most-linked posts?
- C11 – Generic Selections10 people · 10 mentions · first linked 2013-07-30
What Hacker News says?
> and MAYBE extremely limited generics C11 has _Generic, but it's pretty much an abomination: http://www.robertgamble.net/2012/01/c11-generic-selections.h...
Comment linking /2012/01/c11-generic-selections.html
on “The Unreasonable Effectiveness of C (2013)”Submitted C11 – Generic Selections as a story · 2 points
HN discussionSometimes it is a useful sin, many data structure libraries for C use this for: 1) genericity 2) (extreme) speed It's (unfortunately) impossible for C to equal C++ templates in this: write once, use for multiple datatypes (without macros). For people who like copy pasting, generic macros is on the horizon for C11, which is rapidly being implemented (and mostly works) for Clang and GCC, the most important compilers.…
Comment linking /2012/01/c11-generic-selections.html
on “Basics Of Function Pointers In C”Submitted Generics in C11 (2012) as a story · 2 points
HN discussionJava's initial approach/implementation is just one way to do that. If you actually use objects to represent your integers, then of course it will have to do extra checks. But Java is not the best example here, because with a better language you can drop all those checks at the compile time and get the "native integer implementation" in the code where it's used. Even C can do a very basic compile-time generics since…
Comment linking /2012/01/c11-generic-selections.html
on “Swift: Madness of Generic Integer”Submitted C11 - Generic Selections as a story · 1 points
HN discussionIn C11, Type-generic expressions give you something that looks just like overloading ( http://www.robertgamble.net/2012/01/c11-generic-selections.h... ) The declarations do not look nice (I don't think that is a matter of taste in this case, compared to overloading in C++), but for the principled who want to use C or for those who have to use C, there is a solution.
Comment linking /2012/01/c11-generic-selections.html
on “Why I should have written ZeroMQ in C, not C++ (2012)”Type generic expressions [1] already exist in C11. You can do this without a special compiler front-end if you need it, you would just need to define each variant by hand. These are supported in GCC and Clang with the -std=c11 flag. [1]: http://www.robertgamble.net/2012/01/c11-generic-selections.h...
Comment linking /2012/01/c11-generic-selections.html
on “Generics in C without void* or macros – enabled by psychec”#define add(a, b) _Generic(a, int: addi, char*: adds)(a, b) Just because you can doesn't mean you should. Someday, someone will have to read that code. Note that when "add" returns a string, it's done an allocation, but for the integer case, it hasn't called "malloc". Now you'll now need to know the type to get rid of it. Back in C99, generic trig functions were put in to make the number-crunching people happy. Afte…
Comment linking /2012/01/c11-generic-selections.html
on “Function overloading in C”Yep, but for min the C11 generics would work just as well and allow for a bit more flexibility than the older approaches. Though you do have to name mangle manually and they aren't quite as powerful as you'd probably want. http://www.robertgamble.net/2012/01/c11-generic-selections.h...
Comment linking /2012/01/c11-generic-selections.html
on “The MIN Challenge”