Targets
A target selects which declarations participate in the model. It is a named dimension with one selected value: for example, Region might be US or EU. The consumer supplies the selection; a declaration states where it applies.
One product, regional declarations
Catalog Shop {
Product Notebook Region[US] {
Title: "Pocket notebook";
Currency: USD;
PriceCents: 450;
}
Product Notebook Region[EU] {
Title: "Pocket notebook";
Currency: EUR;
PriceCents: 500;
}
Featured: @Notebook;
}
Both declarations describe Notebook. The selected Region determines which one exists in the effective model. Featured keeps the same reference in either case.
| Selected Region | Effective Notebook |
|---|---|
| US | USD, 450 cents |
| EU | EUR, 500 cents |
| Neither region selected | Both alternatives remain; duplicate Notebook is an error |
| A different value | Both alternatives are excluded; Featured cannot resolve |
The selection changes the applicable definition, not its name. A consumer does not need separate references to NotebookUS and NotebookEU.
Supplying a selection
Target selection belongs to the application compiling the document. Nexus Build and
Nexus Forge expose their selections on their command lines. The native API accepts a
TNexusScriptTargetSelection; the embedding example compiles
this Regional model for a selected region and reads Featured.
The standalone NexusScript CLI currently has no /targets option and compiles
without a selection. Do not run Regional through that CLI and expect it to
choose a region. It will correctly retain both declarations and report the
duplicate. The embedding walkthrough provides the complete runnable consumer
for this example.
Alternatives and independent dimensions
This is a declaration fragment inside a catalog:
Product Notebook Region[US, CA] Channel[Retail] { PriceCents: 450; }
US and CA are alternatives within Region. If both Region and Channel are selected, both clauses must match. If Channel is not selected, its clause does not restrict this compilation. A definition without a Region clause is unrestricted by the selected Region.
Names and values are case-sensitive here: Region:US and region:us are
different selections. Each kind occurs once in a definition header, with a
nonempty list of distinct values.
Filtering and relationships
Selection filters definitions before composition and internal reference resolution. A contributor or referenced definition must survive selection. The same selection reaches nested definitions, inline definitions, imported modules, included documents, and dialects.
Target clauses belong to the declaration on which they appear. Composing from another definition does not copy its target clauses onto the receiving definition. Composition combines the retained contributor's content.
Targets select definitions, not individual scalar-property statements. To vary a group of properties, express the relevant definition alternatives or compose from an appropriately selected contributor.
Applying the idea to tools
TargetOS, TargetCPU, and BuildConfiguration are conventions used by Nexus
build consumers. They use the same mechanism as Region; the language does not
hard-code operating systems or compiler switches.
Selecting Release does not itself enable optimization. A recipe definition selected for Release must declare the settings that the compiler consumer uses.
The selected value is also readable as $Region or $TargetOS. That is an
external value, not a quoted-string substitution.
Continue with Documents and assembly.