liveBook · Manning

Setting

As explained in Building User-Friendly DSLs

A value assigned on a language instance for a property from the concept it instantiates.

A setting assigns a value to a property on an instance of a concept. Settings give DSL content its concrete data and can also represent relations between instances. section 1.4.2 section 1.5

When an abstract syntax tree is encoded as JavaScript, settings follow these forms:

  • Store settings as key-value pairs in an AST object's settings subobject. section 3.4
  • Encode multivalued settings as arrays and navigate containment relations through their values. section 3.2.1 section 3.4
  • Encode reference relations as objects whose ref property points to the target AST object. section 3.2.1 section 3.4

Reading and changing settings

For a rental record type, rental.settings["name"] reads the name setting, while rental.settings["attributes"][3] selects its fourth attribute. Updating rental.settings["attributes"][2].settings["initial value"].settings["value"] to 10 changes a nested setting. section 3.2.1

Figure 1.20 Zooming in on the structure aspect of a DSL
figure

Use the structure diagram to connect concepts, properties, instances, and settings. section 1.4.2

How Building User-Friendly DSLs covers it

How deep it goes
Explains conceptual structure and JavaScript encoding, access, relation navigation, mutation, and traversal, without compiler internals.
Examples
Uses car-rental record types, attributes, arrays, reference objects, and nested initial-value updates.
What it assumes
Assumes basic concepts, properties, and instances while defining settings and their JavaScript representations in context.
What you can do after
Operate and modify encoded ASTs by reading settings, following relations, updating values, and traversing their structure.
How it connects
Connects concepts, properties, instances, relations, abstract syntax trees, containment relations, and reference relations.

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.