scheme-bert / README.markdown

scheme-bert

scheme-bert is a BERT (Binary ERlang Term) serialization library for Scheme implementations compliant to R^6RS. BERT is based on Erlang's External Term Format.

See the BERT specification at bert-rpc.org.

Instances of the following Scheme types will be automatically converted to the proper simple BERT type:

  • flonum?
  • integer? (fixnum and bignum)
  • symbol?
  • list?
  • string?
  • vector?

Instances of the following Scheme types will be automatically converted to the proper complex BERT type:

  • 'nil
  • #t
  • #f
  • hashtable?
  • time?

Installation

Installation for Racket:

$ plt-r6rs --install ./src/scheme-bert.ss

(see Installing Libraries for more info)

Usage

Before you load the library module in your code, you have to uncomment appropriate lines of the library source depending on your Scheme implementation. This is caused by how Scheme implementations provide time related functions: Racket depends on SRFI-19, while Chez Scheme has a subset of those listed in the latter.

Issue (import (scheme-bert)) in your REPL or put this in head of your source file. You will also probably want to import some other libraries such as bytevectors.

> (define (bytes)
    (bert-encode (list 'foo 13 42 (vector 666 '() 'bar))))
> (bytes)
#"\203l\0\0\0\4d\0\3fooa\ra*h\3b\0\0\2\232jd\0\3barj"
> (bert-decode (bytes))
{foo 13 42 #(666 () bar)}
>

Caveats

Regular expressions conversion is not supported, because every Scheme comes with its own regexp implementation and I haven't found any portable library which allows one to get the source string and options of a compiled regexp.

Trivia

Please, drop me an email if you used or intend to use the library in your project ;-)

Copyright (c) 2010 Yasir M. Arsanukaev. See LICENSE for details.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.