Hacker News new | ask | show | jobs
by zabzonk 1226 days ago
by your logic, a vector with 3 elements is a different type to a vector with 4 elements. this is where original pascal famously went off the rails
2 comments

If code depends on a vector having 3 or 4 elements, then yes, a vector with 3 elements is a different type than a vector with 4 elements.

It is actually dependent typing.

Not being able to express types properly is a major issue in c++ and in all other programming languages that do not allow this kind of typing.

The lack of this facility prohibits programmers for declaring their intent properly to the compiler, forcing programmers to keep that information in their head.

To me, it's the no 1 issue that c++ must deal with. It will solve a myriad of problems.

Which starts to look an awful lot like dependent types. Unfortunately any sane use-case of that in 2023 looks like Idris or Coq and nobody in C++ today is switching to either of those.