Fat pointer
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
Fat Pointers can be seen as a unification of the "tagged pointer" technique common to dynamic symbolic language implementations, such as Lisps and Smalltalks, and the "vtable" (or "class pointer") technique common to object languages with run-time polymorphism, such as Smalltalks and C++. ~ Mark S. Miller[1]
A fat pointer is a pair of pointers. The first pointer is called the behavior, class, interface, prototype, script, or vtable. The second pointer is called the data, dictionary, frame, instance, locals, or table.
A language can be constructed around adding fat pointers to an existing system. Cello[2], C++, and D add fat pointers to C.
In object-oriented languages like Python, Self, Smalltalk, and Ruby, the fat pointer for an object can be partially deconstructed into two independent pieces. In the most restricted case, a Python or Ruby object might have a custom layout which is computed at runtime and does not cleanly decompose; in the simplest case, Self always treats methods and tables as two distinct referents with independent pointers. These languages often permit changing the class or prototype at runtime, even without the support of a type system.
Languages can use fat pointers as an implementation detail without fully exposing control over the component pointers individually. Languages like D, Go, and Rust use fat pointers to attach dynamic information to existing pointers. Object-capability languages like E and Monte inherit fat pointers from Smalltalk but hide the ability to arbitrarily change an object's script.
References
- ↑ M. S. Miller. Fat Pointers. http://www.erights.org/enative/fatpointers.html
- ↑ D. Holden. A fat pointer library. https://libcello.org/learn/a-fat-pointer-library