On this page:
#%datum
current-datum
default-datum
7.7

3.1 Datum

This library defines an interface for incrementally extending #%datum , solving the problem of diamond inheritance for parsing library-defined data literals.

syntax

(#%datum . syn)

A generic handler for Cur data literals. Calls current-datum to parse syn.

procedure

(current-datum)  (-> syntax? syntax?)

(current-datum p)  void?
  p : (-> syntax? procedure? syntax?)
A phase 1 parameter, holding an open-recursive function for parsing data. Setting current-datum to a new procedure of the right interface effectively extends the #%datum parser. Initially set to default-datum.

Examples:
> 0

eval:1:0: invalid-datum-error: Could not find datum parser

  in: 0

> (require cur/stdlib/nat)
> (begin-for-syntax
    (current-datum (lambda (syn f)
                     (syntax-parse syn
                       [e:nat
                        (nat->unary (syntax->datum syn))]
                       ; User must manually call f if parsing fails.
                       [_ (f syn)]))))
> 0

(z)

procedure

(default-datum syn f)  syntax?

  syn : syntax?
  f : procedure?
The default datum parser; raises an error, as it doesn’t know how to parse anything.