5. Bigloo -- Standard Library 5.4 Serialization

Browsing

Home: | Bigloo A ``practical Scheme compiler'' User manual for version 2.6b December 2003
Previous chapter: | Core Language
Next chapter: | Pattern Matching

Standard Library

5.1 | Scheme Library
| 5.1.1 | Booleans
| 5.1.2 | Equivalence predicates
| 5.1.3 | Pairs and lists
| 5.1.4 | Symbols
| 5.1.5 | Keywords
| 5.1.6 | Numbers
| 5.1.7 | Characters
| 5.1.8 | UCS-2 Characters
| 5.1.9 | Strings
| 5.1.10 | Unicode (UCS-2) Strings
| 5.1.11 | Vectors
| 5.1.12 | Control features
5.2 | Input and output
5.3 | Structures and Records
| 5.3.1 | Structures
| 5.3.2 | Records (SRFI-9)
5.4 | Serialization
5.5 | Bit manipulation
5.6 | Hash Tables
| 5.6.1 | Hash tables
| 5.6.2 | Deprecated Hash tables
5.7 | System programming
| 5.7.1 | Operating System interface
| 5.7.2 | Files
5.8 | Process support
5.9 | Socket support
5.10 | Date
5.11 | Posix Regular Expressions
| 5.11.1 | Regular Expressions Procedures
| 5.11.2 | Regular Expressions Pattern Language
| 5.11.3 | An Extended Example

Chapters

| Acknowledgements
1. | Table of contents
2. | Overview of Bigloo
3. | Modules
4. | Core Language
5. | Standard Library
6. | Pattern Matching
7. | Object System
8. | Threads
9. | Regular parsing
10. | Lalr(1) parsing
11. | Errors and Assertions
12. | Eval and code interpretation
13. | Macro expansion
14. | Command Line Parsing
15. | Explicit typing
16. | The C interface
17. | The Java interface
18. | Bigloo Libraries
19. | Extending the Runtime System
20. | SRFIs
21. | DSSSL support
22. | Compiler description
23. | User Extensions
24. | Bigloo Development Environment
25. | Global Index
26. | Library Index
| Bibliography

string->obj string | bigloo procedure

This function converts a `string` which has been produced by `obj->string` into a Bigloo object.

obj->string object | bigloo procedure

This function converts into a string any Bigloo `object` which does not contain a procedure.

The implementation of the last two functions ensures that for every Bigloo object `obj` (containing no procedure), the expression:

    (equal? obj (string->obj (obj->string obj)))
       => #t

binary-port? obj | bigloo procedure

open-output-binary-file file-name | bigloo procedure

append-output-binary-file file-name | bigloo procedure

open-input-binary-file file-name | bigloo procedure

close-binary-port binary-port | bigloo procedure

input-obj binary-port | bigloo procedure

output-obj binary-port obj | bigloo procedure

input-char binary-port | bigloo procedure

output-char binary-port char | bigloo procedure

Bigloo allows Scheme objects to be dumped into, and restored from, files. These operations are performed by the previous functions. The dump and the restore use the two functions `obj->string` and `string->obj`.
It is also possible to use a binary file as a flat character file. This can be done by the means of `output-char` and `input-char` functions.

register-procedure-serialization serializer unserializer | bigloo procedure

There is no existing portable method to dump and restore a procedure. Thus, if `obj->string` is passed a procedure, it will emit an error message. Sometime, using strict restrictions, it may be convenient to use an ad-hoc framework to serialize and unserialize procedures. User may specify there own procedure serializer and unserializer. This is the role of `register-procedure-serialization`. The argument `serializer` is a procedure of one argument, converting a procedure into a characters strings. The argument `unserializer` is a procedure of one argument, converting a characters string into a procedure. It belongs to the user to provide correct serializer and unserializer.
Here is an example of procedure serializer and unserializer that may be correct under some Unix platform:

    (module foo
       (extern (macro %sprintf::int (::string ::string ::procedure) "sprintf")))

    (define (string->procedure str)
       (pragma "(obj_t)(strtoul(BSTRING_TO_STRING($1), 0, 16))" str))

    (define (procedure->string proc)
       (let ((item (make-string 10)))
          (%sprintf item "#p%lx" proc)
          item))

    (register-procedure-serialization procedure->string string->procedure)

    (let ((x 4))
       (let ((obj (cons "toto" (lambda (y) (+ x y)))))
          (let ((nobj (string->obj (obj->string obj))))
             (print ((cdr nobj) 5)))))

get-procedure-serialization | bigloo procedure

Returns the a pair whose `car` is the current procedure serializer and the `cdr` is the current procedure unserializer.

register-process-serialization serializer unserializer | bigloo procedure

Same as `register-procedure-serialization` for Bigloo processes.

get-process-serialization | bigloo procedure

Same as `get-procedure-serialization` for Bigloo processes.

This Scribe page has been generated by `scribeinfo`.
Last update Tue Dec 16 13:46:41 2003