Hi Kashyap,

> I attempted to use 1 as the CELLS value in pico.h and immediately ran into
> segfault

Yes, this is not a good idea ;)

CELLS is the number of cells per heap

   typedef struct heap {
      cell cells[CELLS];
      struct heap *next;
   } heap;

and PicoLisp allocates as many heaps as needed.

Setting it to 1 creates a huge overhead, because then you'll have one 'next'
link for every cell.

The cells in the heaps are maintained to hold internal linked lists for the
unused cells. Probably this will not work if CELLS is 1.


> Why am I trying CELLS = 1? Just poking around - I was just trying to figure
> out the min number of CELLS I needed for certain programs.

You can get the number of cells in a function with 'size':

   : (size '(a b c))
   -> 3

   : (pp 'test)
   (de test ("Pat" . "Prg")
      (bind (fish pat? "Pat")
         (unless (match "Pat" (run "Prg"))
            (msg "Prg")
            (quit "'test' failed" "Pat") ) ) )
   -> test

   : (size test)
   -> 23

Even a minimal system needs a few thousand cells.

Setting CELLS to just a few dozens would work, but the overhead of maintaining
so many heaps will become relatively large.

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to