You are looking at historical revision 15658 of this page. It may differ significantly from its current revision.
Serialization and deserialization of arbitrary objects.
This extension allows serializing and deserializing arbitrary data (including procedures and continuations) into/from ports. Circular data is support 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.[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.
A separate tool is also available, named chicken-dump that writes a description about the contents of a serialized file. Just invoke
on the command prompt.
- chicken-dump dumps file until eof
- ported to CHICKEN 4
- doesn't use easyffi anymore
- Made fallback-handler more useful and fixed a bug [Thanks to Daishi Kato]
- Added fallback-handler to deserialize
- Nasty little bug in backreferences fixed
- Hash-table-deserialization bug reported by Kabir Soorya
- Fixed small bug in port-serialization; added note about continuations
- Serialization of hash-tables is more storage efficient; added chicken-dump program
- Failure handling for some cases was invalid
- Initial release
Copyright (c) 2005, 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.