Overview

	Erlang external term format serialization for CHICKEN Scheme

Scheme to Erlang objects mapping

   Scheme         Erlang
    ()             []          nil, empty list
    (list 1 2)     [1,2]       list
    (vector 1 2)   {1,2}       tuple
    55             55          integer
    1.0            1.0         floating point
    'oke           oke         atom
    "fire"         "fire"      string
    #${ABBA}       <<16#AB,16#BA>>  binary
    bitstring      <<3:15>>    bitstring

Module

(use erlang-etf)

Exports

(term->binary OBJ) 

; Convert scheme object to erlang term format
; returns bitstring object

(binary->term BINARY)

; Restore scheme object from BINARY (string,blob,etc...)
; returns two values, first scheme object, seconds rest binary bytes

Usage

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(use erlang-etf ; serialization functions
     numbers    ; big numbers
     bitstring) ; bits and byte manipulation

(define bin (term->binary "sector clear!"))

; convert to blob
(print (bitstring->blob bin))

; convert to byte-list
(print (bitstring->list bin 8))

; restore scheme object
(print (binary->term bin))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Implementation details   save load

 Distribution header      -    -
 ATOM_CACHE_REF           -    -
 SMALL_INTEGER_EXT        +    +
 INTEGER_EXT              +    +
 FLOAT_EXT                +    +
 ATOM_EXT                 +    +
 REFERENCE_EXT            -    -
 PORT_EXT                 -    -
 PID_EXT                  -    -
 SMALL_TUPLE_EXT          +    +
 LARGE_TUPLE_EXT          +    +
 NIL_EXT                  +    +
 STRING_EXT               +    +
 LIST_EXT                 +    +
 BINARY_EXT               +    +
 SMALL_BIG_EXT            -    +
 LARGE_BIG_EXT            -    +
 NEW_REFERENCE_EXT        -    -
 SMALL_ATOM_EXT           +    +
 FUN_EXT                  -    -
 NEW_FUN_EXT              -    -
 EXPORT_EXT               -    -
 BIT_BINARY_EXT           +    +
 NEW_FLOAT_EXT            -    -
 ATOM_UTF8_EXT            -    -
 SMALL_ATOM_UTF8_EXT      -    -