[plt-scheme] Help with extending mzscheme.

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Sep 14 14:50:14 EDT 2007

At Fri, 14 Sep 2007 19:42:37 +0100, "dragal V2.0.3" wrote:
> 1. the scheme_malloc_* family of functions segfault if the requested memory
> is unavailable.

See scheme_malloc_fail_ok(), but it's effective at avoiding crashes
only when a large block of memory is requested.

> 2. Is it possible to register a function which is called when a object is
> garbage collected?

See scheme_register_finalizer().

> 3. I have found it desirable to create scheme objects which act as a wrapper
> for the actual game data. [...]
> The best idea I have had is to use a hash map to keep a record of currently
> available wrapper objects and return the appropriate wrapper. However,
> question 2 would have to be possible in order to keep the table updated.

Use a hash table with weakly held keys. At the Scheme level, that's
`(make-hash-table 'weak)'.


Posted on the users mailing list.