Hi Kriangkrai,

> 1. In FFI, it seems that 'boxCnt()' (not 'box()') must be used to
> return a correct value, why?

You are free to use both. 'box()' is the lowest level, it puts a pattern
of 32 bits into a new cell.

         |
         V
      +-----+-----+
      | 32  |  /  |
      +-----+-----+

As I wrote in the last mail, the lowest bit in a number is the sign
bit. 'boxCnt()' takes care of that, shifting the number left and
inserting that bit.

   static inline any boxCnt(long n) {return box(n>=0?  n*2 : -n*2+1);}

>    any f1(any ex) {return box(123);}   //=> -61 in Lisp

 61 * 2 -> 122
 plus sign bit -> 123


> 2. Is whole database in database files is loaded into memory?

No, this is usually not possible. In the project I'm currently working
in, the databases have a size of several hundred gigabytes.

Only when an object is accessed (value, property list etc.), it is
automatically loaded into the Lisp heap as an "external" symbol.


> 3. Is it possible to have the database file a text file (not binary),
> may be a PicoLisp file (like Emacs config file is an Emacs Lisp file)?
> So that the data can be manually edited by a text editor.

The current database files are in a binary format (called "PLIO" for
PicoLisp I/O). This is the same format as written and read by the 'pr'
and 'rd' functions.

A normal text file would be less efficient due to the necessary parsing,
and theoretically possible, but is currently not implemented.


> 4. Could you please explain "hook" in the database library (+Hook and
> the "hook" arguments)?

A hook is an object which contains object-local indexes.

Normally, all objects in the database are searchable by one ore several
criteria (name, number, address, other objects etc.). This is done via
indexes, implemented with B-Trees, which originate in the database root
object.

But sometimes it is necessary to have indexes relative to some other
object. Take, for example, a database of suppliers of products. Each
supplier is an object in the database, having various attributes like
name, address, telephone etc. Besides that, there are articles (items or
products) associated with that supplier. Each article has a unique item
number, but unique perhaps only in the context of that supplier, not
globally. Thus, the index of article numbers will be local to that
supplier. Each article has a (+Hook +Link) to the supplier and the item
number will be hooked to that supplier.

   (rel sup (+Hook +Link) (+Supplier))  # The link to the supplier in article
   (rel nr  (+Key +Number) sup)         # The article number, hooked to 'sup'

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to