Design and Philosophy of CML2

CML2, therefore, has a view of the world that includes both menus and rules. A CML2 system specifies the following things:

  • A tree of menus. This tree is explicitly declared by the CML2 programmer. Each menu contains a sequence of questions; each answer to a question sets the value of a configuration symbol. Menus may also contain submenus.

  • A set of visibility predicates. At any given time, only a subset of the menu tree is visible. Each node in the tree (each symbol or menu) has a predicate associated with it that controls whether it is visible or suppressed. Input (independent) variables in the predicate may be set from CML2's startup options, or they may be set by the results of previous queries.

  • A set of validity constraints. These are predicates that connect two or more configuration symbols. Each constraint is checked every time the user tries to change the value one of its input symbols; if the constraint would not be satisfied by the change, the change is disallowed and the user notified. Other, user-interface-dependent actions to recover from the constraint violation may follow.

  • A set of derivations. A derivation is a formula that ties the value of an output symbol to the value of one or more input symbols. Derived symbols may be either be computed for direct use in a final configuration, or used as input variables of constraints or predicates. Whenever a derived symbol is evaluated, the formula behind it is recomputed from the current values of the formula's input symbols (like a cell in a spreadsheet).

This is a very different view of the world from CML1's conventional imperative one, and will have significant implementations for configuration file maintainers. Notably, the CML1 configuration tree had multiple apices: one top-level config-language file for each port subdirectory. CML2 defines one big menu tree, with portions suppressed during the configuration process.

Some indication of the power of these concepts may be gleaned from the compression ratio of CML1-to-CML2 translation. The 7049 lines of CML1 in the 2.3.99-pre9 kernel tree became fewer than 2400 lines of CML2, and it would have been less if I had not been adding sanity checks and reorganizing it as I went along.