From: Pekka Niiranen
Subject: Question for theoreticans: Ultimate object format
Date: 
Message-ID: <42446e79$0$26170$39db0f71@news.song.fi>
Call me crazy, but

I just recently read Daniel N.Ozieck article
"A lisp-style library for C" from Dr Dobbs (AUG91).
Then I studied Randall Hyde's book Write Great Code vol. 1
which explained HLA's string as structure of
"MAXLENGHT|LENGTH|STRING\0" and its benefits. Furthermore,
I read the thread in comp.lang.scheme news group about
the optimal way of storing unicode. Those set me thinking:

If one would like to create a fixed size (in bytes) structure
to represent all possible Common Lisp objects
(including unicode strings) what should it look like?
Let's forget wasting memory (ain't we past that? its cheap) and
concentrate making consing fixed size memory operation
despite the types of primitive values. I am thinking of
some short of unification of array and list types where
number of consed elements is the total length of the array and
lists are doubly linked. Consing would increase MAXLENGTH slot
of structure and as an optimation some lists are internally
stored as arrays etc. Surely somebody must have thougth these before.

Since I am using AMD64 I was playing also with an idea
of using first LO byte of 64bit value as type tag since:
- I could use one byte assembly commands to access tag data fast.
- that would still leave 56bits for data
   (true, 56bit integers sounds odd but is still more than 32bits;))

Any comments?

-pekka-

From: Christopher C. Stacy
Subject: Re: Question for theoreticans: Ultimate object format
Date: 
Message-ID: <usm2jgze9.fsf@news.dtpq.com>
Pekka Niiranen <··············@wlanmail.com> writes:

> Call me crazy, but
> 
> I just recently read Daniel N.Ozieck article
> "A lisp-style library for C" from Dr Dobbs (AUG91).
> Then I studied Randall Hyde's book Write Great Code vol. 1
> which explained HLA's string as structure of
> "MAXLENGHT|LENGTH|STRING\0" and its benefits. Furthermore,
> I read the thread in comp.lang.scheme news group about
> the optimal way of storing unicode. Those set me thinking:
> 
> If one would like to create a fixed size (in bytes) structure
> to represent all possible Common Lisp objects
> (including unicode strings) what should it look like?

Every object would be represented by one word (eg. 32 or 64 bits),
where about three of the bits are encoded to indicate the general
type of the object, and the remainder form a machine address
where the object is located.   At that address, depending on the
type-tag of this pointer, you might find either the data itself,
or some sort of object header that gives further details that is
followed by the data.

>I am thinking of some short of unification of array and list types

Lisp has many more data types than lists and arrays, so this 
question doesn't seem to be particularly related to the above.
For data types that are indexed multiple ways, consult an 
introductory computer science (data structures and algoriths) text.
From: Pekka Niiranen
Subject: Re: Question for theoreticans: Ultimate object format
Date: 
Message-ID: <4246fbd7$0$27694$39db0f71@news.song.fi>
Christopher C. Stacy wrote:
> Pekka Niiranen <··············@wlanmail.com> writes:
> 
> 
>>Call me crazy, but
>>
>>I just recently read Daniel N.Ozieck article
>>"A lisp-style library for C" from Dr Dobbs (AUG91).
>>Then I studied Randall Hyde's book Write Great Code vol. 1
>>which explained HLA's string as structure of
>>"MAXLENGHT|LENGTH|STRING\0" and its benefits. Furthermore,
>>I read the thread in comp.lang.scheme news group about
>>the optimal way of storing unicode. Those set me thinking:
>>
>>If one would like to create a fixed size (in bytes) structure
>>to represent all possible Common Lisp objects
>>(including unicode strings) what should it look like?
> 
> 
> Every object would be represented by one word (eg. 32 or 64 bits),
> where about three of the bits are encoded to indicate the general
> type of the object, and the remainder form a machine address
> where the object is located.   At that address, depending on the
> type-tag of this pointer, you might find either the data itself,
> or some sort of object header that gives further details that is
> followed by the data.

Thanks, I also found an article called "history of T" where
similar ideas were expressed.
> 
> 
>>I am thinking of some short of unification of array and list types
> 
> 
> Lisp has many more data types than lists and arrays, so this 
> question doesn't seem to be particularly related to the above.
> For data types that are indexed multiple ways, consult an 
> introductory computer science (data structures and algoriths) text.
I will do that ("simultaenously indexed multiple ways" is
what I was thinking about).