[Ecls-list] C-embedding buglets

Rudi Schlatte rschlatte at ist.tu-graz.ac.at
Mon Dec 17 23:21:03 UTC 2001


Greetings,

I've played a bit with the C interface of ECL.  Some things that I
stumbled over:

- All the macros work only when prefixed with "ffi:", i.e.
  (ffi:defcbody ...) instead of (defcbody "...").  Failing to do this
  yields messages like

;;; Compiling (DEFCBODY LOGAND ...).
;;; The variable LOGAND is undefined.
;;; The compiler will assume this variable is a global.
;;; The variable FIXNUM is undefined.
;;; The compiler will assume this variable is a global.

  for the LOGAND example from the manual.  During a (cursory) search,
  I did not find the place where these symbols are interned / created
  in the cl-user package, so no patch for this one, sorry.

- The example given in the manual for definline does not compile.  It
  should probably read

(definline aref-byte (string fixnum) fixnum
           "(#0)->string.self[#1]")

- I missed an entry for conses and lists in the node "Manipulating
  Lisp Objects", documenting documenting CONS(..), CAR, CDR,
  make_list(n, ...).

- There is a neat trick in gcc to embed a block in an expression that
  is of use in defcbody and friends.  Something like the following
  could be put in the node "Embedding C code in Lisp source":

The gcc compiler, which is used by ecl, sports a non-standard
extension for embedding a whole block inside an expression.  This
comes in handy when the function to be defined with defCbody needs,
for example, local variables.  To use it, enclose a normal C block
ending with an expression in parens.  The value of this last
expression is the value of the whole block.  A silly example,
returning a list containing the logical AND of two fixnums:

(defCbody logand-list (fixnum fixnum) object 
   "({cl_object return_value; 
      return_value = CONS(MAKE_FIXNUM(#0 & #1), Cnil); 
      return_value;})")

  (Feel free to incorporate the text into the manual, with thanks for
  providing a nice system for playing with.)

Regards,

Rudi




More information about the ecl-devel mailing list