procedure
[ out#:keep-mutable?keep-mutable?#:handle-failhandle-fail#:external-lift?external-lift?#:skip-prefix?skip-prefix?])v:any/cprocedure
[ #:datum-intern?datum-intern?#:external-liftsexternal-lifts
The v argument must be a value that could be quote d as a literal—that is, a value without syntax objects for which (compile `',v) would work and be read able after write —or it can include correlated objects mixed with those values. The byte string produced by s-exp->fasl does not use the same format as compiled code, however.
If a value within v is not valid as a quote d literal, and if handle-fail is not #f, then handle-fail is called on the nested value, and the result of handle-fail is written in that value’s place. The handle-fail procedure might raise an exception instead of returning a replacement value. If handle-fail is #f, then the exn:fail:contract exception is raised when an invalid value is encountered.
If external-lift? is not #f, then it receives each value v-sub encountered in v by s-exp->fasl . If the result of external-lift? on v-sub is true, then v-sub is not encoded in the result, and it instead treated as externally lifted. A deserializing fasl->s-exp receives a external-lifts vector that has one value for each externally lifted value, in the same order as passed to external-lift? on serialization.
Like (compile `',v), s-exp->fasl does not preserve graph structure, support cycles, or handle non-prefab structures. Compose s-exp->fasl with serialize to preserve graph structure, handle cyclic data, and encode serializable structures. The s-exp->fasl and fasl->s-exp functions consult current-write-relative-directory and current-load-relative-directory (falling back to current-directory ), respectively, in the same way as bytecode saving and loading to store paths in relative form, and they similarly allow and convert constrained srcloc values (see Printing Compiled Code).
Unless keep-mutable? is provided as true to s-exp->fasl , then mutable values in v are replaced by immutable values when the result is decoded by fasl->s-exp . Unless datum-intern? is provided as #f, then any immutable value produced by fasl->s-exp is filtered by datum-intern-literal . The defaults make the composition of s-exp->fasl and fasl->s-exp behave like the composition of write and read .
If skip-prefix? is not #f, then a prefix that identifies the stream as a serialization is not written by s-exp->fasl or read by fasl->s-exp . Omitting a prefix can save a small amount of space, which can useful when serializing small values, but it gives up a sanity check on the fasl->s-exp that is often useful.
The byte-string encoding produced by s-exp->fasl is independent of the Racket version, except as future Racket versions introduce extensions that are not currently recognized. In particular, the result of s-exp->fasl will be valid as input to any future version of fasl->s-exp (as long as the skip-prefix? arguments are consistent).
> fasl#"racket/fasl:0ε24ε34ε3ε 1ε23ε5εspeed16ε5εracer\r!"
'(#("speed") racer #\!)
Changed in version 6.90.0.21 of package base: Made s-exp->fasl format version-independent
and added the #:keep-mutable?
and #:datum-intern? arguments.
Changed in version 7.3.0.7: Added support for correlated objects.
Changed in version 7.5.0.3: Added the #:handle-fail argument.
Changed in version 7.5.0.9: Added the #:external-lift? and #:external-lifts arguments.
Changed in version 8.9.0.4: Added support for fxvectors and flvectors.