4.11. Default values of kinds

| Chapter 4: Kinds |

| 4.11. Default values of kinds

Just about every kind has a "default value". Inform needs this when it knows that something has to be a value of a given kind, but it hasn't been told what the value is. For example, in the previous chapter we saw that every thing has a "description" text, but we also created plenty of things without describing them. So if Inform reads

> The conference pear is in the bowl.

and it isn't told anything else about the pear, what should it set the description of the pear to?

The answer is that Inform knows the description has to be a value of the kind "text", so it uses the default value of "text". Not very interestingly, this is just the blank text "".

Being uninteresting is exactly the idea, of course. The default number is 0, for instance. (Default values are tabulated in the Kinds index.)

It's sometimes useful to be able to refer to the default value of a kind without having to spell out what this is (especially if the kind is something obscure, or we're trying to write a rule for an extension which has to work in situations we don't fully know about).

default value of (name of kind) ... value

Produces the default value of the kind named. Examples: The silver repeater is here. "You catch sight of a silver repeater watch, hands immobile at [default value of time]." produces the output: You catch sight of a silver repeater watch, hands immobile at 9:00 am. because nine in the morning is the default time in Inform. If we have: Brightness is a kind of value. The brightnesses are guttering, weak, radiant and blazing. then "default value of brightness" is guttering, the first brightness created. When it comes to kinds of object, we sometimes have to be a little careful. For example, default value of room is always going to be fine (it's always the first room created in the source text). But default value of vehicle would produce a Problem message if there were no vehicles in the world.

Previous | Contents | Next