Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C11 introduced type generic expressions.


Not in the commonly understood sense of "generics", no. You get to switch on a type, but you don't have generic functions or types. A reusable, type-safe Vec or HashMap are still not possible in C...


Kind of, now that typeof is going to be part of the language, that coupled with the preprocessor, does allow exactly that.

Although in typical C fashion is a bit of kludge.


"coupled with the preprocessor" is a bit of a cop-out :-). Do you have a concrete example of what typeof would enable? Like a basic implementation of a vector type?


True, it is basically //go: generate, before Go was born.

Here is an example, https://codereview.stackexchange.com/questions/101816/generi...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: