|
|
|
|
|
by anandology
2551 days ago
|
|
Any slice implementation that references to the original data has to be some kind of "fat pointer". Is there any other way that can be done? String.substring in Java does exactly that. I'm sure numpy arrays in Python are implemented like that, perhaps slightly more fatter. |
|
Yes, add one more level of indirection.
For instance traditional "oo" languages don't usually use fat pointers for dynamic dispatch, you have a single pointer to an instance which holds a pointer to its vtable.
In Rust however, the "object pointer" is a fat pointer of (vtable, instance). Go's interface pointers are the same (which combined with nils leads to the dreaded "typed nil" issue).