![]() | Chapter 14: Units | ![]() ![]() |
14.7. More on specifications |
The essential requirement is that the specification must be one that clearly specifies no other kind. So "10 specifies a weight" will not be allowed, because 10 specifies a number already: but "10kg specifies a weight" is allowed because the "kg" suffix safely distinguishes it.
The specification can run for more than one word: we could instead have had written either of these -
10kg net specifies a weight.
10 kg specifies a weight.
In fact, we are allowed to say all three:
A weight is a kind of value. 10kg specifies a weight. 10kg net specifies a weight. 10 kg specifies a weight.
They will then all be allowed as alternatives. The first one given will be the one Inform considers the "normal" notation, so that will be the one used when weights are printed back in text.
For most units representing physical quantities, it is unnatural to write negative values, and so Inform will issue a Problem message if this is tried - for instance, Inform would not allow us to write a weight of -4 kg. (This doesn't mean that arithmetic on units is forbidden to get a negative result: we may want to work out the difference between two weights. Inform's Problem message is simply to try to prevent the accidental writing of incorrect values.) If we do want the ability to write possibly negative values of the unit in source text, we need make the specification form itself negative:
-10 kg specifies a weight.
This alerts Inform that both positive and negative values for this unit can sensibly be written in source text.
Previous | Contents | Next |