Hacker News new | ask | show | jobs
by quotemstr 425 days ago
And those index values are just pointers by another name!
1 comments

It's not "just pointers", because they can have additional semantics and assurances beyond "give me the bits at this address". The index value can be tied to a specific container (using new types for indexing so tha you can't make the mistake of getting value 1 from container A when it represents an index from container B), can prevent use after free (by embedding data about the value's "generation" in the key), and makes the index resistant to relocation of the values (because of the additional level of indirection of the index to the value's location).
Yes, but like raw pointers, they lack lifetime guarantees and invite use after free vulnerabilities