► |  | The Racket Reference

1 | Language Model
2 | Notation for Documentation
3 | Syntactic Forms
4 | Datatypes
5 | Structures
6 | Classes and Objects
7 | Units
8 | Contracts
9 | Pattern Matching
10 | Control Flow
11 | Concurrency and Parallelism
12 | Macros
13 | Input and Output
14 | Reflection and Security
15 | Operating System
16 | Memory Management
17 | Unsafe Operations
18 | Running Racket
| Bibliography
| Index

▼ | 13 | Input and Output

13.1 | Ports
13.2 | Byte and String Input
13.3 | Byte and String Output
13.4 | Reading
13.5 | Writing
13.6 | Pretty Printing
13.7 | Reader Extension
13.8 | Printer Extension
13.9 | Serialization
13.10 | Fast-Load Serialization

On this page:

s-exp->fasl
fasl->s-exp

top ← prev up next →

#### 13.10`` Fast-Load Serialization

(require racket/fasl) | package: base

The bindings documented in this section are provided by the racket/fasl library, not racket/base or racket.

> procedure (s-exp->fasl v [out]) → (or/c (void) bytes?)
> v : any/c
> out : (or/c output-port? #f) = #f
> procedure (fasl->s-exp in) → any/c
> in : (or/c input-port? bytes?)

The s-exp->fasl function serializes v to a byte string, printing it directly to out if out is an output port or return the byte string otherwise. The fasl->s-exp function decodes a value from a byte string (supplied either directly or as an input port) that was encoded with s-exp->fasl.

The v argument must be a value that could be quoted as a literal, because s-exp->fasl essentially uses (compile `',v) to encode the value using Racket’s built-in fast-load format for bytecode.

The byte-string encoding produced by s-exp->fasl is specific to a version of Racket. That is, the resulting byte string can be decoded back to v only using the same version with which it was encoded.

Examples:

> > (define fasl (s-exp->fasl (list #("speed") 'racer #\!)))
> > fasl
> #"#~\0036.8T\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0'\0\0\0\221(\t\24z\221\3\1\5insp0'\20\0\20\0\25_\20\1\6\5\5speedCracer\a!"
> > (fasl->s-exp fasl)
> '(#("speed") racer #\!)

top ← prev up next →