I7:kind

From IFWiki

In Inform 7, a kind is a type of object, such as a room, a door, or a person.

In object-oriented programming terms, a kind is Inform's name for a class, a data structure with a defined set of attributes, properties, and methods, which can be used as a blueprint for creating specific instances of that class. For example, container is a standard kind, and the programmer can define a specific container with a simple declaration:

The treasure chest is a container.

The treasure chest inherits all the properties of a standard container, but the programmer may now modify any of the chest's inherited properties or add new properties as required. If the game requires many treasure chests, the programmer might instead decide to create a new kind of container called the treasure chest. This is also easily done:

The treasure chest is a kind of container.

And the programmer can now create instances of specific treasure chests:

Bluebeard's chest is a treasure chest.

Note that unlike classes in Inform 6 and TADS, Inform 7 does not support multiple inheritance for its kinds. It is not possible, for example, to define a horse as both a vehicle and an animal. Every item and kind in a game inherits from at most one parental kind. Four of the standard kinds (room, thing, direction, and region) are just kinds; they do not inherit from some überkind.

All instances of a kind are objects. Objects are a kind of value; that is, an object is one of Inform 7's datatypes. Object is not a kind. One cannot create instances of object, nor create kinds of object. Assertions like "A forcefield is an object" or "An odor is a kind of object" are invalid.

Standard kinds

Standard Rules by Graham Nelson defines 15 basic kinds:

  • animal. A kind of person (that is, creature) who isn't a human being.
  • backdrop. A kind of non-portable thing that appears in multiple rooms.
  • container. A kind of thing that can have something else inside it.
  • device. A kind of thing that can be switched on and off.
  • direction. An object like north, southwest, or up.
  • door. A kind of non-portable thing that acts as a conduit between two rooms.
  • man. A kind of person who is male (and usually human).
  • person. A kind of thing that is a living creature.
  • player's holdall. A kind of portable container into which excess inventory items are automatically put.
  • region. An object that represents a collection of rooms.
  • room. An object that represents a location in the game world.
  • supporter. A kind of thing that can have something else on top of it.
  • thing. An object (other than a room) that exists in the game world.
  • vehicle. A kind of container that people can enter.
  • woman. A kind of person who is female (and usually human).
This article is a stub. You can help IFWiki by expanding it.
TODO: Still need to talk about the keyword; that it's a noun (plural: kinds); what assertions/phrases "kind" is used in; what "kind of value" means/does; include an inheritance tree for the standard kinds.