CompilerTopThreadsC Interface

C Interface

A simple mechanism (available through the goo/x module) is provided to inline C code directly into GOO, escaping back into GOO when necessary, and relying on C for its type system instead of having to mirror it in GOO. On the downside, there is no static checking, and errors can occur during C compilation.
 #" ... "# Liberal String S
Allows for the easy specification of strings (especially C code snippets) with special character escaping turned off.
 C-MENT (C-MENT [,c-snippet ,goo-form]*) S
Specifies a C statement formed as the concatenation of c-snippets (goo strings) and GOO forms 2. The GOO forms are evaluated at runtime as embedded C expressions in the lexical context of the c-ment expression. If specified at top level, then the c-ment form will be evaluated prior to the evaluation of non c-ment top level forms.
 C-EXPR (C-EXPR [,c-snippet ,goo-form]*) S
Same as c-ment but specifies a value producing C expression instead.
 to-c (x) G
user extensible protocol for converting a GOO object to a C value. Methods are provided for <int>, <flo>, <str>, <chr>, <log>, and <loc>.
 #{ ... } Inlined C Statement S
Shorthand for c-ment allowing GOO forms to be specified with a $ prefix and the conversion of GOO objects into C values specified with an @ prefix, with @x == $(to-c x). For example,
(df f (x) #{ printf("Got %lx", $x); })
prints out the GOO value x. A callback can be defined at top level as follows:
#{ int gl_idle(int x) { $(gl-idle); } }
C headers can be included similarly:
#{ #include "GL.h" }
C expressions can be nested within embedded GOO expressions as follows:
#{ int gl_idle(int x) { $(gl-idle #ei{ x }); } }
in order to access lexical apparent C variables etc.
 #ec{ ... } Inlined C Expression S
Similar shorthand for c-expr also allowing a single character code c for specifying the conversion of C values back to GOO objects. The valid codes are i for <int>, f for <flo>, s for <str>, c for <chr>, b for <log>, l for <loc>, g for none. For example,
(d. $gl-line-loop #ei{ GL_LINE_LOOP })
defines a top-level OpenGL constant.
 USE/LIBRARY (USE/LIBRARY ,name) S
adds ,name to list of libraries to be linked against.
 USE/INCLUDE (USE/INCLUDE ,name) S
adds ,name to include directory search path.


CompilerTopThreadsC Interface