DPL 9 Help

Underspecifying Values (DPL Code)

Underspecifying Values (DPL Code)

DPL also allows you to underspecify the number of values. If there are fewer initialization expressions than expected, DPL will set the remaining values to 0.

chance Fire_Damage.{High, Medium, None} = {0.2, 0.5} =
   50000,10000;

DPL will automatically assign a value of 0 to the final state of this chance event. Beware: The fact that DPL does this can cause problems if you have misspecified the values because you will not get an error message. For example, the following definition will not work as expected.

value Profit | Revenues, Costs = Revenues - Costs;

This definition will result in Profit being assigned the difference between Revenues and Costs only when Revenues and Costs are each in their first states. All other times, Profit will be assigned a value of 0. The correct definition is:

value Profit = Revenues - Costs;

Versions: DPL Professional, DPL Enterprise, DPL Portfolio

See Also

The Definition Section