vile / scheme / datum_to_syntax.v
10 lines · 9 sloc · 499 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1module scheme
2
3// Syntax may be partially unwrapped pair/vector structure. Existing wrapped
4// fragments retain their exact handles; only ordinary symbols gain context.
5fn datum_to_syntax(template Value, datum Value) !Value {
6 info := syntax_identifier_info(template)!
7 object := syntax_object_ref(template)!
8 if datum.tag !in [.pair, .vector, .symbol] { return datum }
9 return map_anchored_syntax_value_graph(datum, true, syntax_identifier_context(template)!, info.wrap, object.data.owner, info)
10}
11