Skip to content

Dotted Keys Explained

In CCL, dotted keys are literal string keys containing dots, not shorthand for nested structures.

These create different data structures:

/= Dotted key: literal string
database.host = localhost
/= Hierarchical nesting
database =
host = localhost

The dotted-key example creates Entry("database.host", "localhost"). The hierarchical example creates Entry("database", "host = localhost"); after build_hierarchy(), it becomes {database: {host: "localhost"}}.

Dotted keys use the literal string:

get_string(config, "database.host") // ✓ Works
get_string(config, "database", "host") // ❌ No nested object

Hierarchical data uses nested access:

get_string(config, "database", "host") // ✓ Works
get_string(config, "database.host") // ❌ No literal key
/= Hierarchical (recommended)
database =
host = localhost
port = 5432
/= Dotted keys
database.host = localhost
database.port = 5432
/= Do not mix styles: this creates separate keys
database =
host = localhost
database.port = 5432

Some implementations provide an opt-in expand_dotted function that rewrites dotted keys into nested structures. This is experimental and tracked under the experimental_dotted_keys feature tag. Standard typed accessors (get_string, get_int, etc.) take separate path segments; they do not interpret "a.b" as a path.