www.delorie.com/gnu/docs/guile/guile_134.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.3 Defining New Types (Smobs)

Smobs are Guile's mechanism for adding new non-immediate types to the system.(5) To define a new smob type, the programmer provides Guile with some essential information about the type -- how to print it, how to garbage collect it, and so on -- and Guile returns a fresh type tag for use in the first word of new cells. The programmer can then use scm_c_define_gsubr to make a set of C functions that create and operate on these objects visible to Scheme code.

(You can find a complete version of the example code used in this section in the Guile distribution, in `doc/example-smob'. That directory includes a makefile and a suitable main function, so you can build a complete interactive Guile shell, extended with the datatypes described here.)

18.3.1 Describing a New Type  
18.3.2 Creating Instances  
18.3.3 Type checking  
18.3.4 Garbage Collecting Smobs  
18.3.5 A Common Mistake In Allocating Smobs  
18.3.6 Garbage Collecting Simple Smobs  
18.3.7 A Complete Example  

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003