Inform 7 Home Page / Documentation


§27.21. Inform 6 objects and classes

As might be expected, I7 compiles an I6 class for each kind, and an I6 object for each of its own objects. We can meddle with its compilation process here using a further refinement of Include. For instance, suppose we want the I6 class definition for things to come out containing a property like this:

Class K2_thing ...
    with marmalade_jar_size 6,
    ...

How to arrange this? One way is to create an ordinary I7 property, like so:

A thing has a number called marmalade jar size. The marmalade jar size of a thing is usually 6. The marmalade jar size property translates into I6 as "marmalade_jar_size".

(Without that last sentence, the property won't get any familiar name.) But sometimes we need more, and want to actually write new material to go into the definition. This can be done like so:

Include (- with before [; Go: return 1; ], -) when defining a vehicle.

This glues in a new property to the class compiled to represent the I7 kind "vehicle". (See the DM4 for why. However, since the entire actions machinery is different in the I7 world, note that "after", "react_before" and "react_after" no longer have any effect, and nor does "before" for rooms.)

And similarly:

Include (- has my_funny_attribute, -) when defining the hot air balloon.

If we need a particular I7 object or kind to end up with a particular I6 name, we can write:

The whatsit object translates into I6 as "whatsit".
The thingummy kind translates into I6 as "thingummy_class".

WARNING: The "Include (- ... -) when defining ..." usage still works for the moment (except in projects compiled to C at the command line, where it may fail), but it is deprecated and likely to be removed in later versions of Inform. Avoid it if at all possible.


arrow-up.png Start of Chapter 27: Extensions
arrow-left.png Back to §27.20. Primitive Inform 6 declarations of rules
arrow-right.png Onward to §27.22. Inform 6 variables, properties, actions, and attributes