Inform: Things, Kinds, and other Words Of Very Definite Meaning

Inform’s definitions make me pause. I want to write a short post summarizing some main ideas: Things, which are sort of like objects; Kinds, which are sort of like classes; Actions, which are sort of like, well, functions with side effects; Values, which I guess are also like objects? Or instances? Or just values?

If I were learning nearly any other programming language, this uncertainty would be non-existent. Even when things are non-standard I could say things like, “Oh, well Lua can do objects but it implements them unusually via tables.” I think the reason I feel so uncertain here is that Inform is under no pretense of writing a manual aimed at programmers.

Here’s a fantastic example, from the start of the chapter of Writing with Inform on “Kinds”:

4.1. New kinds

Values are to Inform what nouns are to English sentences. They represent numbers, times of day, pieces of text, places, people, doors, and so on. Because they have such an enormous variety, and because we often want to talk about what some of them have in common, we need a way to sort all of these different ideas out. That’s the main aim of Inform’s concept of “kind”.

I’m all well and good with what nouns are, but the programmer part of me wants to scan for words like “variable”, “object”, “constant”, or even “type”. Inform avoids these programmerly terms with such consistency that it simply can’t be an accident. It’s like the authors are saying, “Look, we talk about kinds of things because that’s the kind of thing that people understand. If we go on about classes somebody’s going to think they’re going to be assigned homework and start having flashbacks of that final exam they failed in tenth grade, and we can’t have that.”

The other reason for caution is that Inform isn’t doing things the way I’m used to. It’s not primarily a procedural language, but a rule based one. Rather than defining a main loop and writing interface code and programming logic in sequence, you simply define what exists and what rules govern the way things relate to each other.

visual index of an Inform project
The index that Inform generates for your project gives a good high-level idea of how it defines and classifies your code.

So I’m tempted to compare Inform’s ‘kinds’ to classes. But there are important caveats. Kinds aren’t meant to visually encapsulate or organize code in the way that object-oriented programming usually does. You can define verbs and relationships that act on particular kinds of objects, but those definitions exist wherever you decide to put them in your story file. Verbs in this case are sort of like a class method, but verbs themselves aren’t ‘attached’ to a class. It reminds me a bit of how Common Lisp handles methods, where the objects in question still have to be passed as parameters because of the list structure of CL code. In a sense CL methods are simply functions defined for a particular class of parameter. Similarly, Inform code can have verbs defined to operate on a particular kind of noun.

Leave a Reply

Your email address will not be published. Required fields are marked *