You can store the "next" in a list cell if you want, but there still has to be some way to figure out, given just the object, which cell it corresponds to. Well, you could traverse the whole list to find it, but I sure hope you understand why that's a bad idea. Sure, compute a hash---but that computation is overhead.
Why do you think Java distinguishes Integer from int? If it were possible to have integers that walked, talked, and quacked like an object, but without any overhead, then we wouldn't use integers. We'd use those things instead.
> Why do you think Java distinguishes Integer from int?
Because the compiler writers didn't want to spend effort using tagged types or compiler optimization techniques.
The original goal was to generate bytecode for simple execution in embedded devices.
.NET for example, does not distinguish between Integer and int. One is the alias for the other.
Eiffel INTEGER is mapped to a plain C int[0], when generating native code.
Smalltalk implementations usually use byte tagging to map primitive objects to register sizes. Described in the blue book.
Ada Integer has quite a few pre-defined attributes and the language allows for additional user defined attributes[0]. Additionally one can specify the amount of bits used for storage.
Any good CS compiler design course would cover such cases in detail.
You can store the "next" in a list cell if you want, but there still has to be some way to figure out, given just the object, which cell it corresponds to. Well, you could traverse the whole list to find it, but I sure hope you understand why that's a bad idea. Sure, compute a hash---but that computation is overhead.
Why do you think Java distinguishes Integer from int? If it were possible to have integers that walked, talked, and quacked like an object, but without any overhead, then we wouldn't use integers. We'd use those things instead.