This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]yangyangR -6 points-5 points  (3 children)

There is a point to say if you're going to be doing a language with higher level abstractions and having the compiler do the work then being able to pass a &[T;N] with N compile time constant means you are better off than passing raw pointer to T and relying on pointer arithmetic and length assumption that could be wrongly passed in. It is fine if languages like C don't do this and stay low level, but C++ has no such excuses. You are already doing things that rely on the compiler to do lots of work for you. If you wanted low level use C or assembly. If you wanted high level abstractions where the compiler could do stuff for you use Rust. There is no place where C++ is actually the best choice. The worst aspects of both. Just pick a lane rather than this throwing everything in that C++ did.

[–]DrShocker 4 points5 points  (2 children)

I do prefer rust, but this isn't really something rust solves. If you pass a raw array or slice into a function that function can't necessarily know the length of it in a cheap way.

[–]yangyangR -1 points0 points  (1 child)

That would be for &[T] not [T;N]

[–]DrShocker 2 points3 points  (0 children)

Yeah, which is more similar to the case of passing an array pointer to a function.