1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
open! Core_kernel
open! Import
module Q = struct
let defconst = "defconst" |> Symbol.intern
end
let all_defconst_symbols = ref []
module Private = struct
let all_defconst_symbols () =
!all_defconst_symbols |> List.sort ~compare:Symbol.compare_name
;;
end
let defconst_i symbol here ~docstring ~(type_ : _ Value.Type.t) ~value =
all_defconst_symbols := symbol :: !all_defconst_symbols;
Load_history.add_entry here (Var symbol);
Form.list
[ Form.symbol Q.defconst
; Form.symbol symbol
; Form.quote (type_.to_value value)
; Form.string (docstring |> String.strip)
]
|> Form.eval_i
;;
let defconst symbol here ~docstring ~type_ ~value =
defconst_i symbol here ~docstring ~type_ ~value;
Var.create symbol type_
;;