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

C and C++ could both easily add this feature:

https://www.digitalmars.com/articles/C-biggest-mistake.html

which is adding slices to the native language. This will eliminate buffer overflow errors (if the user uses that feature). D has had this from the beginning, and while it doesn't cover everything, that feature alone has resulted in an enormous reduction in memory safety errors.

BTW, D also has a prototype ownership/borrowing system.




C++20 added std::span, which is essentially that.


Without bounds checking.


Hey. Be reasonable. That's coming in c++26 using the `.at` interface that no one actually uses because `[]` is more natural, shorter (2.5x shorter), and convenient.


Yeah, that is exactly the problem. :)




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

Search: