In smalltalk you cannot reference an element of array,
only the object (array in that case) as a whole.
The reason why it like so, because VM moves objects around, and you cannot control directly when that happens,
and also VM responsible for updating all pointers (references) to moved object(s)
for all interested parties (which could be other objects, stack etc) , making sure all references remain consistent upon such move.
So, with such constraints, the only way to validly point to an element inside array
would be to store two values separately:
��- a reference to an object, that represent your buffer (which VM would update at will)
��- an index (or offset) in that object, pointing to element in your buffer
Unfortunately, this is the only way how we could implement such, lets say 'ElementPointer' safely. Which then can be used to pass to C function(s),
converting object reference + offset into simple address just before invoking a function (and sure thing, knowing that there's no chance triggering GC, else it will turn into pointer to wrong place, but that's general problem of passing pointers on object memory heap, not just exclusively for 'element pointer' and such).
For buffers allocated externally, e.g. outside heap governed by VM,
there's nothing prevents you from having an address that pointing inside some buffer (or even outside it :)
��
For NBExternalAddress:
addr := self allocate: somespace.
newAddr := NBExternalAddress value: addr value + someoffset.
or
newAddr := addr copy value: addr value + someoffset