6.10 mischief/quotation: Quoting Values as S-expressions
(require mischief/quotation) | package: mischief-dev |
procedure
x : any/c
custom : (-> any/c (or/c (-> (-> any/c any/c) any/c any/c) #false)) = (const #false)
Produces an s-expression representing an expression that would evaluate to
x. Can be customized using #:custom; see
custom-quoter below for an example.
Example:
procedure
(custom-quoter pred proc)
→ (-> any/c (or/c (-> (-> any/c any/c) any/c any/c) #false)) pred : predicate/c proc : (-> (-> any/c any/c) any/c any/c)
Produces a custom quotation procedure that quotes values satisfying
pred using proc and leaves everything else to default
quotation.
Examples:
> (struct both [one two])
> (define (quote-both rec b) `(both ,(rec (both-one b)) ,(rec (both-two b))))
> (quotation (both (list (both 1 2)) 3) #:custom (custom-quoter both? quote-both)) '(both (list (both 1 2)) 3)