3 ms·
Because objects in Smalltalk encapsulate their representation, it's not possible (without using reflection) to figure out exactly how an object represents itsel
by tonyg 8y ago
Because objects in Smalltalk encapsulate their representation, it's not possible (without using reflection) to figure out exactly how an object represents itself. So things that would be primitives in other languages, like small integers, are in Smalltalk ordinary objects like anything else. The language works hard to present a 'uniform object model'.
However! When the rubber meets the road, there has to be some kind of bit-level representation somewhere. In Smalltalk, the VM hides these details from the programmer, who gets to reason uniformly about objects without caring about their representation. Specifically, Smalltalk VMs often use pointer tagging [0] just like lots of other dynamic languages do.
[0] Lots of interesting stuff on pointer tagging here: https://www.snellman.net/blog/archive/2017-09-04-lisp-numbers/ https://www.snellman.net/blog/archive/2017-09-04-lisp-number...