Note:

The C type SCM is used to describe the objects manipulated in Scheme. PRIMITIVE is an alias for this type; it is preferably used when defining a new primitive.

STk_add_new_primitive tells the interpreter that the Scheme symbol posix-time must be bound to the (C written) primitive posix_time. The constant tc_subr_0 used as the second argument indicates the arity of this primitive. In this case, the arity of the primitive is 0.

Let's now have a look at the primitive posix-ctime. A first writing of this primitive could be
\begin{Code}
\begin{listing}[200]{2}
static PRIMITIVE posix_ctime(void)
{
char ...
...(NULL);
\par
s = ctime(&t);
return STk_makestring(s);
}
\end{listing}\end{Code}

This functions uses another interpreter routine (STk_makestring) which takes as parameter a null terminated string and returns a Scheme string.

Binding of the scheme symbol time-string to the C function get_time is done by the call
\begin{Code}
\begin{listing}[200]{2}
STk_add_new_primitive(''posix-ctime'', tc_subr_0, posix_ctime);
\end{listing}\end{Code}

A complete listing of this code is given in Figure [*]. Provided that we have done a shared object of this file, and that its name is posix.so, our two new primitives can be loaded dynamically by:
\begin{Code}
\begin{listing}[200]{2}
(load ''time.so'')
\end{listing}\end{Code}