It's like an object-oriented BCPL.

2003-08-09 15:20

Inform is one of the coolest languages ever. It’s a language for writing text adventures.

What makes it really neat is that it’s an incredibly, well, weird language. It’s a language designed for two goals:

1. It can compile easily to the Z-machine, the virtual machine Infocom used for their old text adventures.
2. It’s good at modern text adventures.

As a result, it has very strange convenience features, and a lot of odd rules. The syntax is weirder than perl. And, underneath it all, the language is basically designed to hurt your head. Got a variable? It could be a string, a dictionary word, an object, or maybe even just a number. You can tell which, sometimes, but I don’t know how that works.

Here’s a sample of what Inform looks like:

  Object -> MuddyPrints "muddy footprints"
    has  scenery,
    with  description "A trail of muddy footprints. Why don't
             adventurers ever wipe their feet?",
      name 'muddy' 'prints' 'footprints' 'mud' 'floor' 'trail',
      before [;
      Smell: "Eww. That's not mud.";
        remove self;
        "You clean up the muddy footprints.";

That defines an object. The ““ means that this object is contained within the last object declared with no ->‘s in it. (> -> is another level of containment, and so on.)

“has” introduces attributes – these are predefined flags, which are either true or false. “with” introduces properties, each of which is a 16-bit value, or perhaps an array of 16-bit values. The ones in single quotes are “dictionary words” – words the game’s parser will recognize. “[;” introduces a subroutine.

If you have a subroutine for “before”, that’s called before the game allows an action. As a convenience to the user, it is treated as though the user had written “switch (Action)” before any unattached labels found within it, and put the needed ##‘s in front of the labels. (I can see the eyes glazing over from here.)

But it’s a really good language for this stuff. It’s quirky, yes, but those footprints worked perfectly from very early on in the game. Not hard to write. Not all that hard to understand. It’s worth learning, if you have any interest at all in telling interesting stories.

Peter Seebach