2 ms·
> As far as I understand, in a dependent type system it should be possible to implement a resizable array "std::vector<int, n>", where n is the length of the ar
by jcelerier 6y ago
> As far as I understand, in a dependent type system it should be possible to implement a resizable array "std::vector<int, n>", where n is the length of the array (a variable), then write a "concat" function which concatenates two such arrays, and whose return (static) type depends on the lengths of the arrays passed as arguments.
worksforme https://gcc.godbolt.org/z/x9GjE7KGM https://gcc.godbolt.org/z/x9GjE7KGM (ok, except the "resizeable" bit - but since we're doing functional programming we want immutable data structures, no ? :p)
- yakubin 6y ago"n" is not a variable in your example. It's still just syntactic sugar for templates, where the n needs to be known statically. Even without the "resizable" bit, you still limit this function to operating on arrays of sizes known statically, which is a severe limitation, making the whole thing impractical.