Gambit-c reviewed. 18:54 (tech_notes#87)


1) follow path business to get up and running:



as per documentation also:

$ ln -s /usr/local/Gambit-C/lib/libgambc.a /usr/lib # name may vary $ ln -s /usr/local/Gambit-C/include/gambit.h /usr/include

gsi, gsc executables.

example again from manual for m1.c m2.scm and m3.scm:

cd doc
bash-3.00# cat m1.c
/* File: "m1.c" */
int power_of_2 (int x) { return 1<<x; }
bash-3.00# cat m2.scm
; File: "m2.scm"
(c-declare "extern int power_of_2 ();")
(define pow2 (c-lambda (int) int "power_of_2"))
(define (twice x) (cons x x))
bash-3.00# cat m3.scm
; File: "m3.scm"
(write (map twice (map pow2 '(1 2 3 4)))) (newline)
bash-3.00# gcc m1.c m2.c m3.c m3_.c -lgambc -lm -ldl -lutil
bash-3.00# ./a.out
((2 . 2) (4 . 4) (8 . 8) (16 . 16))

Gambit-C particularly under examples/distr-comp for promiscuOS

from README:

This example is a distributed application composed of two nodes
(running in the same Scheme process).  A thread is started on the
first node.  The thread performs a loop.  At each iteration of the
loop it prints the name of the node it is running on, then the thread
migrates to the other node.  This example can easily be changed so
that each node is running on a different machine.  Say the machines
are "foo.com" and "bar.com".  The machine "foo.com" should run

(define (main)
   9000 ; TCP port-number for this node
   'foo ; name of the first node
   (lambda () 'no-op)))

An the machine "bar.com" should run

(define (main)
   9000 ; TCP port-number for this node
   'bar ; name of the second node
   (lambda ()
     ; start a thread on bar.com
      (let ((n1 (current-node))
            (n2 (make-tcp-node "foo.com" 9000 'foo)))
        (let loop ((i 0) (a n1) (b n2))
          (if (= i 100)
                (if #t
                      (pp (list i 'from (current-node-name))
                      (force-output (current-output-port))
                      (thread-sleep! .1)))
                (goto b)
                (loop (+ i 1) b a)))))))))