Hacker News new | past | comments | ask | show | jobs | submit login

Root problem is the lack of namespaces in C, making collisions inevitable and painful to deal with



C doesn't even need namespaces for this, a simple stdc_ prefix for stdlib functions and types would also work (see C23 stdbit.h, I hope this won't be an outlier).


With proper namespaces you can import stuff so you don't have to prefix with the namespace every time.


Yes, but we can't simply port C++ namespaces over because this requires symbol name mangling. C could be using 'namespace prefixes' instead with something like 'usingprefix stdc_', this wouldn't require changes to the symbol format, and would provide most of the features of C++ namespaces.


That gets very ugly very quick for something as basic as e.g. memcpy or strcmp.


C23 technically has to support namespaces for attributes. It'll be interesting to see if they get adopted into the core language at some point.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: