2.2. Constructing objects

On each of the following sections we will document the standard interface for building objects of different types. For some objects, though, it is too difficult to make a C interface that resembles all of the functionality in the lisp environment. In those cases you need to

  1. build the objects from their textual representation, or

  2. use the evaluator to build these objects.

The first way makes use of a C or Lisp string to construct an object. The two functions you need to know are the following ones.

 Function: cl_object c_string_to_object (const char *s)
 Function: cl_object string_to_object (cl_object o)

c_string_to_object builds a lisp object from a C string which contains a suitable representation of a lisp object. string_to_object performs the same task, but uses a lisp string, and therefore it is less useful. Two examples of their use

    /* Using a C string */
    cl_object array1 = c_string_to_object("#(1 2 3 4)");

    /* Using a Lisp string */
    cl_object string = make_simple_string("#(1 2 3 4)");
    cl_object array2 = string_to_object(string);