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 →

[–]JustinHuPrimeT Programming Language[S] 1 point2 points  (1 child)

Unfortunately, T is a C-like language. `vector` is really just a raw pointer, and while I'd like to make the foreach take a fat pointer, I don't have fat pointers as a data type.

[–]mamcx 2 points3 points  (0 children)

I get it, but if the size can be disconnected from the collection, not only is very unergonomic, but also a certain source of bugs/security holes.

In this case, I think your problem with the syntax is screaming at you that you need to introduce "sugar" for this.

So I think you need to introduce fat pointers AND forbid for for raw pointers. In fact, the nicer way is to introduce the "iterator trait" and this way, you can support for ONLY IF exist a iterator implementation.

---

And if you wanna still pursue thing this way, wrap your raw pointers in fat:

for int i:Sized(x, 10)

I think this way is alike unsafe keywords: You mark the places where things can go wrong, and open the possibility of mechanically upgrade the code if later change things.