[Prev][Next][Index][Thread]
Re: Harlequin 1.2 still available?
Hugh Greene wrote in message ...
>An alternative is to reserve a few "tag" bits in the first word of each
>object to encode a very few possibilities like "integer", "character" or
>"other object". Then you only need the extra word for "other objects".
>This possibility is why the DRM only guarantees 28 bits for integers, not
>32 (I believe FunDev provides 29 bits).
I had a slightly different understanding of how this works: isn't it the
object *reference* that has a few reserved bits, rather than the object
itself? That is, most objects consist of an allocated chunk of memory with
a type-tag word followed by the object's data. When you pass the object
around or store it in a variable, you're really passing around a pointer or
handle to that chunk of memory. But with tagged integers, there's no
allocated memory at all. Rather, the handle that you pass around actually
contains the integer's value, along with a bit indicating that it's an
immediate integer rather than a reference to an allocated object.
It's not just a matter of avoiding using an extra word of memory to store
the object's type tag. It's a matter of avoiding one level of indirection,
and avoiding doing memory allocation and garbage collection every time you
create a new integer "object". In fact there are no integer objects, at
least not at the implementation level.
At least, what I'm describing is the way it works in Smalltalk, AFAIK. Is
Dylan doing something different here?
Follow-Ups:
References: