liveBook · Manning

Reference resolution

As explained in Building User-Friendly DSLs

Reference resolution is the process of replacing serialized reference representations with references to the corresponding in-memory AST objects.

Reference resolution replaces serialized reference objects such as { refId: <ID> } with AST reference objects pointing to the corresponding in-memory AST object. Deserialization creates a new AST rather than modifying the serialized value, preserving unresolved references whose ID is undefined as { ref: undefined }. section 7.3 section 7.6

A practical deserializer resolves references through these steps:

  • Detect serialized reference objects separately from AST objects, arrays, and primitive values. section 7.3
  • Traverse the serialized AST recursively and construct fresh AST objects for each serialized AST object. section 7.3
  • Index each constructed AST object by ID so serialized references can locate their targets. section 7.6

Resolving a rental-price attribute reference

A rental price after discount can refer to the rental price before discount through an encoded wrapper such as { ref: rentalPriceBeforeDiscountAttribute }. After serialization, that relation becomes { refId: "SlLaELvAy0" }; deserialization restores the reference to the in-memory Data Attribute object.

How Building User-Friendly DSLs covers it

How deep it goes
Explains recursive traversal, ID indexing, deferred resolution, and undefined targets, while stopping short of broader graph algorithms.
Examples
Uses rental-price attributes, serialized reference IDs, lookup tables, and a JSON contents file restored for pretty printing.
What it assumes
Assumes AST objects, reference wrappers, serialization, and recursive traversal; teaches ID-based restoration during deserialization.
What you can do after
Apply via JavaScript to deserialize persisted AST JSON and restore references for frontend or backend use.
How it connects
Connects ASTs with serialization, deserialization, JSON, reference relations, and observable state.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.