Serialization and deserialization of arbitrary objects.
See this ticket for a bug related to hash-tables deserialization.
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 X #!optional PORT SERIALIZERprocedure
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 #!optional PORT DESERIALIZERprocedure
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.
- really fixed handling of keywords (thanks to Kon Lovett)
- fixed handling of keywords
- ported to CHICKEN 5
- 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-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.