Hi Tomas,

> >       xxxxxxxxxxxxxxxxxxxxxxxxxxxxx010 Number
> >       xxxxxxxxxxxxxxxxxxxxxxxxxxxxx100 Symbol
> >       xxxxxxxxxxxxxxxxxxxxxxxxxxxxx000 Cell
> 
> A cell consists of two pointers, isn't it 64 bits on 32 bit picoLisp2
> then?

Yes. The above patterns show the format of the pointers (in 32 bits).


> Same for miniPicoLisp, isn't a cell 128 bits big when compiled on 64
> bit platform?

Right.


> What the "raw data" mean in doc/structures there?  I am puzzled by
> "bin".

That's what I called the "convoluted structures" ;-)

'bin' is a word (32 or 64 bits) completely without tag bits. It can be
used totally for binary data, in places where the type is clear from the
context. It is the same as the 'DIG' data in the CAR parts of bignums in
picoLisp[23]. I just did not want to call it 'DIG' in miniPicoLisp,
because it does not represent digits there, but only the packed
characters of symbol names.

'txt', the other "raw data" term, is a little tricky. As you see, it
uses the least significant bit as a tag bit, which is normally not
allowed, because this bit is reserved for the garbage collector.
However, 'txt' is used exclusively for short symbol names, completely
fitting into the CAR part of a symbol cell, and the garbage collector
only uses bit zero in the CDR part of each cell. In this way, symbols
with up to 5 characters fit into a single pointer on a 32 bit machine
(as lowercase characters, space and a few punctuations occupy 6 bits in
miniPicoLisp).


> Why is the size of things documented as 8 bits for miniPicoLisp?

This was just to keep it unspecified, as opposed to picoLisp2 which is
restricted to 32, and picoLisp3 to 64 bits.


> > That is, a number is still indicated by an AND with 2, or an atom with
> > 6. Note, however, that you cannot directly check for a symbol here,
> > because a number may also have bit three on. To determine if a given
> > datum is a symbol, it must first be asserted that it is not a number.
> 
> Can't you just say something like:
> 
> num  if (X & 3) == 2
> sym  if (X & 7) == 4
> cell if (X & 7) == 0

Yes, this would be the same, because bit zero is always 0 in normal
(i.e. non-gc) operation. But the comparison with '==' is unnecessary and
would generate an additional "compare" instruction, while

   (X & 2)  or  (X & 3)

which is the same as

   (X & 2) != 0

generates a single AND or TEST instruction.

But for the assertion of a symbol, as I wrote above, a double check is
necessary in miniPicoLisp and picoLisp3:

   (X & 6) == 4  # On 32bit miniPicoLisp
   (X & 12) == 8  # On 64 bit miniPicoLisp

and even

   (X & 14) == 8  # On picoLisp3


> >    cnt   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxS010
> >    big   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxS100
> >    sym   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1000
> >    cell  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0000
> >
> > We have an additional tag bit, and use it to differentiate between short
> > numbers and bignums. The 'S' bit in each type is the sign bit. So a
> > number can be identified by ANDing with 6, a symbol with 8, and so on.
> 
> No, you can't determine symbol by anding with 8 because that would
> clash with the sign bit of cnt and big?  I am really puzzled now;-) Is

Totally correct. This is what I wanted to say with:

> > because a number may also have bit three on. To determine if a given
> > datum is a symbol, it must first be asserted that it is not a number.

Practically, there are two possibilities:

1. You know from the context that the data item is not a number. The
   most typical example is EVAL (e.g. in miniPicoLisp):

   #define EVAL(x)         (isNum(x)? x : isSym(x)? val(x) : evList(x))

"If x is a number, return it. Otherwise, if it is a symbol ..."

So here it is sufficient to AND with 4 or 8 to find out if we have a
symbol. For other cases you have to do the full double check with AND
and CMP. These cases are not so frequent, because most functions will
check for a number type first to either handle it or generate an error
message.


> it some trick with "symbol names are simply combined big and short
> numbers"?
> 
> I would say:
> 
> cnt  if X & 2
> big  if X & 4
> sym  if (X & f) == 8
> cell if (X & f) == 0

Correct (if this was for picoLisp3, the many versions get confusing ;-)



> > The implementation of 6-and-a-half bits for ASCII characters in
> > miniPicoLisp does not allow for UTF-8 support or external symbol
> > encodings.
> 
> This is serious.  However, could not be miniPicoLisp more clever and
> use as many bits as possible (like picoLisp2 and 3 do) instead of
> being limited to 8 bits?

Yes, we could use a combination with the other systems. This would
probably make sense for 64bit miniPicoLisp, as the 'txt' data item has
63bits instead of just 31.


> class continuations like scheme does.  Have you thought about using
> the picoLisp heap instead of the traditional C stack?

Yes, I experimented with that, but did not find a better solution. The
hardware stack seems optimal for certain things. On the other hand, it
is always worth to explore other possibilities.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to