Appending to variables

The syntax

varname ( predname1, predname2, ... ) += "value"
(note the "+=" operator) can be used to append values to variables depending on whether predicates are true. The "+=" lines in the META file are evaluated one after the other, and every line is selected for which the formal predicates are satisfied, and these lines are added to the current value of the variable. This is different from the "=" operator where only the most specific assignment is taken.

The values are considered as space-separated words when they are appended, i.e. the new words are added to the list of current words.

For example, in the hypothetic META file

var(p) += "a"
var(p,q) += "b"
the value of var is "a b" if both p and q are true, and the value is only "a" is only p is true (and the value is empty otherwise). If the operator "=" had been used, the value would have been only "b" when both p and q are true.

In the case that there both "=" and "+=" settings for the same variable, a special algorithm is used: First the most specific "=" setting is determined, and second all matching "+=" settings are appended in the order they appear in the file.

Finally, here is a real-world example. Imagine you have an archive p.cma and a special extension for the toploop, p_top.cma. Furthermore, there is a special debugging version p_dev.cma that replaces p.cma during development. You can now simply write

archive(byte) = "p.cma"
archive(byte,development) = "p_dev.cma"
archive(byte,toploop) += "p_top.cma"
to select either p.cma or p_dev.cma, and append p_top.cma for toploops to whatever was selected in the first step.