Structure, values, and identity
A definition has a kind and a name. Its body holds properties and child definitions. These are the pieces on which references and composition operate.
Names identify; kinds describe
In Product Notebook, Product is the kind and Notebook is the name.
Two products can have different names while sharing the same kind. Two catalogs
can each contain a product named Notebook because the parent supplies scope.
The scope of a name is the surrounding structure in which that name is
looked up. Shop.Notebook and Outlet.Notebook identify children in different
catalogs. Having a name does not make a definition globally accessible from
every other definition; reference lookup
has specific rules.
Ordinary definition, property, and named-array lookup is case-insensitive.
Notebook and notebook cannot be used as two distinct siblings.
Target names/values and external identities have different, case-sensitive
rules, introduced in their own chapters. Preserve spelling consistently even
where lookup ignores case.
Properties and children
Catalog Shop {
Title: "Corner Stationery";
Product Notebook { Title: "Pocket notebook"; }
}
Title is a property whose value is text. Notebook is a child definition
with its own kind and properties. Neither is implicitly an instance of a Pascal
class. A consumer decides how to represent or use the compiled information.
Do not declare a property and child with the same name in one definition. Likewise, repeating a property in one body is an error, not an assignment that updates an earlier statement. Composition supplies the explicit mechanism for combining contributions from different definitions.
Text and text composition
Catalog Shop {
Currency: USD;
Title: "Corner Stationery";
PriceCents: 450;
Available: True;
Heading: @Title + " / " + @Currency;
Literal: "$Region @Title";
Lines: "first^nsecond";
}
USD, 450, and True are scalar text. Quoting is useful for spaces and
essential when punctuation must be preserved exactly. + joins scalar text;
it does not add numbers. Heading resolves to Corner Stationery / USD.
The @Title operand is an internal reference, covered next.
Quoted text does not interpolate @ or $: Literal contains those characters
unchanged. The escape character is ^, with ^^, ^", ^n, ^r, and ^t
for caret, quote, newline, carriage return, and tab. Backslash is ordinary text.
Quote paths, decimals, and other punctuation-sensitive values.
Arrays are ordered values
Catalog Shop {
Tags: [stationery, gifts];
Captions: [Short: "Shop", Long: "Corner Stationery"];
Groups: [Primary: [stationery, office], Seasonal: [gifts]];
Products: [
Product Notebook { Title: "Pocket notebook"; },
Display: Product Pencil { Title: "Graphite pencil"; }
];
}
Tags has two unnamed scalar entries. Captions has named scalar entries; their
names allow references such as @Captions.Short from within Shop. Groups
contains named arrays.
Products contains inline definitions: definitions written as array entries.
Notebook's effective entry name is its declared name, Notebook. The second
entry explicitly chooses Display as its array name while retaining Pencil as
the original definition name. Use @Products.Display.Title to address its title.
An array can contain text, nested arrays, inline definitions, and references. A dialect may narrow those choices. Entry order is retained. Named entries must be unique within one array; unnamed scalar entries may repeat.
An inline definition is written inside an array. For a single structured value, declare a child definition and refer to it from a property. That makes its identity and sharing explicit.
Written form and effective value
Title: "Notebook"; writes text directly. Title: @OtherTitle; writes a
reference whose effective value may be text. A dialect can distinguish those
source forms while also requiring that the resulting value be text.
That distinction matters for validation and for preserving relationships. Resolving a value does not erase the fact that it came from a reference.
Continue with References.