On this page:
quotation
custom-quoter

6.10 mischief/quotation: Quoting Values as S-expressions🔗ℹ

 (require mischief/quotation) package: mischief-dev

procedure

(quotation x [#:custom custom])  any/c

  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:
> (quotation (list (vector 1 2) (box "three")))

'(list (vector 1 2) (box "three"))

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)