s11n

  1. s11n
    1. Description
    2. Author
    3. Repository
    4. Requirements
  2. Caveats
    1. Usage
      1. serialize
      2. deserialize
      3. chicken-dump
    2. History
    3. License

Description

Serialization and deserialization of arbitrary objects.

Author

felix winkelmann

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/s11n

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Requirements

None

Caveats

See this ticket for a bug related to hash-tables deserialization.

Usage

This extension allows serializing and deserializing arbitrary data (including procedures and continuations) into/from ports. Circular data is supported, as well as uninterned symbols. Foreign-pointer objects and ports other than the default input-, output- and error-ports can not be serialized. Threads may be serialized provided they are not running or ready (this means suspended or created but not yet started threads).

The serialized data is endianness- and word-size dependent. Compiled procedures and continuations can be deserialized, provided that the same executable or libraries are loaded/linked - the compiled code must be available so that the deserialization process can find the associated code.) Continuations can be serialized but care has to be taken about what exactly is stored in such an object. Every invocation of call-with-current-continuation includes the complete list of pending dynamic-wind thunks (and their dynamic environment) which is likely to include non-serializable state.

serialize

[procedure] (serialize X [PORT [SERIALIZER]])

Writes a binary representation of X into PORT which defaults to the value of (current-output-port). If the serialization is unable to handle some object, the procedure SERIALIZER is invoked with that object as it's sole argument. The procedure should either signal an error or return a placeholder object that is to be serialized instead. If no serializer is specified, an error will be signalled.

deserialize

[procedure] (deserialize [PORT [DESERIALIZER]])

Reads a binary representation of a Scheme data object from PORT which defaults to the value of (current-input-port). The deserialized object is returned.

If DESERIALIZER is given, then it will be called for procedure objects that can not be deserialized (normally because a serialized file was generated by a different version of CHICKEN) with the procedure-id (internal name) and the deserialized closure object as argument.

chicken-dump

A separate tool is also available, named chicken-dump that writes a description about the contents of a serialized file. Just invoke

 chicken-dump FILENAME

on the command prompt.

History

0.9.12
now can deserialize hash-tables (thanks to Idiomdrottning)
0.9.10
really fixed handling of keywords (thanks to Kon Lovett)
0.9.9
fixed handling of keywords
0.9.8
ported to CHICKEN 5
0.9.3
chicken-dump dumps file until eof
0.9.2
ported to CHICKEN 4
0.9
doesn't use easyffi anymore
0.8
Made fallback-handler more useful and fixed a bug [Thanks to Daishi Kato]
0.7
Added fallback-handler to deserialize
0.6
Nasty little bug in backreferences fixed
0.5
Hash-table-deserialization bug reported by Kabir Soorya
0.4
Fixed small bug in port-serialization; added note about continuations
0.3
Serialization of hash-tables is more storage efficient; added chicken-dump program
0.2
Failure handling for some cases was invalid
0.1
Initial release

License

 Copyright (c) 2005-2019, Felix Winkelmann.  All rights reserved.
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the Software),
 to deal in the Software without restriction, including without limitation
 the rights to use, copy, modify, merge, publish, distribute, sublicense,
 and/or sell copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following conditions:
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.