liveBook · Manning

Dereferencing

As explained in Building User-Friendly DSLs

Obtaining the target object of a relation by following a direct object reference.

Dereferencing obtains the target object of a relation by following a direct JavaScript object reference. In the AST representation, a reference is wrapped in an object under a property such as settings.attribute.ref; evaluating that expression directly reaches the referenced AST object. section 3.1.2

This approach avoids ID lookup during ordinary AST interaction. ID-based references would require finding the target, potentially by traversing the entire AST, whereas direct references are simple and fast. Actual object IDs become necessary when ASTs are serialized to or deserialized from JSON. section 3.1.2

const rentalPriceAfterDiscountInitialValue = {
    concept: "Attribute Reference",
    settings: {
        "attribute": {
            ref: rentalPriceBeforeDiscountAttribute
        }
    }
}

Shows an attribute-reference AST object whose ref property points directly to the rental-price attribute. section 3.1.2

How Building User-Friendly DSLs covers it

How deep it goes
Defines direct dereferencing and contrasts it with ID resolution, deferring actual IDs until JSON serialization.
Examples
Demonstrates an attribute reference from rentalPriceAfterDiscountInitialValue to rentalPriceBeforeDiscountAttribute.
What it assumes
Assumes JavaScript object references and AST objects, while defining dereferencing in the reference-relation context.
What you can do after
Apply it via JavaScript object references to obtain related AST objects without performing ID lookups.
How it connects
Connects ASTs with reference relations, JavaScript object references, ID-based resolution, serialization, and deserialization.

Also explained in

Compare how 3 books explain dereferencing →

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.