[gambit-list] Creating and returning scheme lists inside C functions?

TJay tjay.dreaming at gmail.com
Fri Dec 30 15:27:51 EST 2005


How do I create a scheme list inside a C function, and return that
list? I couldn't find any documentation on this, so I searched through
gambit.h and came up with this, which fails to compile due to "___hp"
being "undeclared".

___hp seems to be used in the definition of ___CONS.

;;========================================
;; Is this the correct way to create lists?

(c-declare #<<c-declare-end

___SCMOBJ getList () {
  ___SCMOBJ *a, *b, *c;
  ___S8 one, two, three;

  one = 1;
  two = 2;
  three = 3;

  return
  ___CONS(one,
          ___CONS(two,
                  ___CONS(three,
                          ___NUL)));
}

c-declare-end
)

(define get-list
  (c-lambda () scheme-object "getList"))

(read) ;So that I can enter the REPL by interrupting the program.

;;========================================




~ TJay ~



More information about the Gambit-list mailing list