Skip to content
Surf Wiki
Save to docs
technology/programming-languages

From Surf Wiki (app.surf) — the open knowledge base

Inform

Programming language and design system


Programming language and design system

FieldValue
nameInform
logo[[File:Inform 7 IDE Icon.png]]
authorGraham Nelson
developerGraham Nelson
latest release version10.1.2
latest release date{{cite web
urlhttps://github.com/ganelson/inform/blob/master/notes/release/10-1-0.md
titleRelease notes for Inform v10.1.0 and v10.1.1
access-date2022-08-26
publishergithub.com
operating systemMicrosoft Windows, Mac OS X, Linux, others
genreInteractive fiction development and play
licenseArtistic 2.0
websitehttps://ganelson.github.io/inform-website/
Note

the programming language

| access-date = 2022-08-26 Inform is a programming language and design system for interactive fiction originally created in 1993 by Graham Nelson. Inform can generate programs designed for the Z-code or Glulx virtual machines. Versions 1 through 5 were released between 1993 and 1996. Around 1996, Nelson rewrote Inform from first principles to create version 6 (or Inform 6).{{cite web | access-date = 2015-11-07

Z-Machine and Glulx

The Inform compilers translate Inform code to story files for Glulx or Z-code, two virtual machines designed specifically for interactive fiction. Glulx, which can support larger games, is the default.

The Z-machine was originally developed by Infocom in 1979 for their interactive fiction titles. Because there is at least one such interpreter for nearly every major and minor platform, this means that the same Z-code file can be run on a multitude of platforms with no alterations. Originally Inform targeted the Z-machine only.

Andrew Plotkin created an unofficial version of Inform 6 that was also capable of generating files for Glulx, a virtual machine he had designed to overcome many of the limitations of the several-decades-old Z-machine. Starting with Inform 6.3, released February 29, 2004, Inform 6 has included official support for both virtual machines, based on Andrew Plotkin's work. Early release of Inform 7 did not support Glulx, but in August 2006 Glulx support was released.

Inform 6

| access-date = 2024-12-04

Inform was originally created by Graham Nelson in 1993. In 1996 Nelson rewrote Inform from first principles to create version 6 (or Inform 6). Over the following decade, version 6 became reasonably stable and a popular language for writing interactive fiction.

The Inform 6 system consists of two major components: the Inform compiler, which generates story files from Inform source code, and the Inform library, a suite of software which handles most of the difficult work of parsing the player's text input and keeping track of the world model. The name Inform also refers to the Inform programming language that the compiler understands.

Although Inform 6 and the Z-Machine were originally designed with interactive fiction in mind, many other programs have been developed, including a BASIC interpreter, a LISP tutorial (complete with interpreter), a Tetris game, and a version of the game Snake.

The Inform 6 compiler

The Inform compiler generates files for the Z-machine or Glulx (also called story files) from Inform 6 source code.

The Inform 6 programming language

The Inform programming language is object-oriented and procedural. A key element of the language is objects. Objects are maintained in an object tree which lists the parent–child relationships between objects. Since the parent–child relationship is often used to represent location, an object which is the parent of another object is often said to "hold" it. Objects can be moved throughout the tree. Typically, top level objects represent rooms and other locations within the game, which may hold objects representing the room's contents, be they physical items, non-player characters, the player's character, or background effects. All objects can hold other objects, so a livingroom object might hold an insurancesaleman object which is holding a briefcase object which contains the insurancepaperwork object.

In early versions of Inform, objects were different from the notion of objects from object-oriented programming, in that there was no such thing as a class. Later versions added support for class definitions and allowed objects to be members of classes. Objects and classes can inherit from multiple classes. Interactive fiction games typically contain many unique objects. Because of this, many objects in Inform do not inherit from any class, other than the "metaclass" Object. However, objects very frequently have attributes (boolean properties, such as scenery or edible) that are recognized by the Inform library. In other languages this would normally be implemented via inheritance.

Here is a simple example of Inform 6 source code.

! Square brackets define a routine. This is the Main routine, which takes no arguments.
[ Main;
    print "Hello, World!^";
];

The procedual parts, statements and operators, are largely borrowed from C, with the notable exception that instead of is used to take array subscripts. Routines are defined in square brackets, as in the routine above,

Inform 6 library

The Inform system also contains the Inform library, which automates nearly all the most difficult work involved in programming interactive fiction; specifically, it includes a text parser that makes sense of the player's input, and a world model that keeps track of such things as objects (and their properties), rooms, doors, the player's inventory, etc.

The Inform compiler does not require the use of the Inform library. There are several replacement libraries available, such as Platypus{{cite web | access-date = 2007-01-04

Example game

Here is an example of Inform 6 source code that makes use of the Inform library. The Inform 6 code sample below is usable in Inform 7, but not without special demarcation indicating that it is embedded legacy code.

Constant Story "Hello Deductible";
Constant Headline "^An Interactive Example^";

Include "Parser";
Include "VerbLib";

[ Initialise;
    location = Living_Room;
    "Hello World";
];

Object Kitchen "Kitchen";
Object Front_Door "Front Door";

Object Living_Room "Living Room"
    with
        description "A comfortably furnished living room.",
        n_to Kitchen,
        s_to Front_Door,
    has light;

Object -> Salesman "insurance salesman"
    with
        name 'insurance' 'salesman' 'man',
        description "An insurance salesman in a tacky polyester
              suit.  He seems eager to speak to you.",
        before [;
            Listen:
                move Insurance_Paperwork to player;
                "The salesman bores you with a discussion
                 of life insurance policies.  From his
                 briefcase he pulls some paperwork which he
                 hands to you.";
        ],
    has animate;

Object -> -> Briefcase "briefcase"
    with
        name 'briefcase' 'case',
        description "A slightly worn, black briefcase.",
    has container;

Object -> -> -> Insurance_Paperwork "insurance paperwork"
    with
        name 'paperwork' 'papers' 'insurance' 'documents' 'forms',
        description "Page after page of small legalese.";

Include "Grammar";

Notable games developed in Inform 6 or earlier versions

  • Curses, by Graham Nelson (1993), the first game ever written in the Inform programming language. Considered one of the first "modern" games to meet the high standards set by Infocom's best titles.{{cite web | access-date = 2006-11-01
  • Zork: The Undiscovered Underground (1997), written by Marc Blank & Michael Berlyn, programmed by Gerry Kevin Wilson. Given away free by Activision to promote the release of Zork: Grand Inquisitor.
  • Anchorhead, by Michael S. Gentry (1998) is a highly rated horror story inspired by H. P. Lovecraft's Cthulhu Mythos.Of the 1219 games rated at "Interactive Fiction Ratings", Anchorhead was the highest rated game as of January 4, 2007. ({{cite web | access-date = 2007-01-04 | archive-date = May 11, 2008 | archive-url = https://web.archive.org/web/20080511194344/http://www.carouselchain.com/if/statistics.php | url-status = dead
  • Photopia, by Adam Cadre (1998), the first almost entirely puzzle-free game. Won the annual Interactive Fiction Competition in 1998.
  • Varicella by Adam Cadre (1999). It won four XYZZY Awards in 1999 including the XYZZY Award for Best Game, and had a scholarly essay written about it.{{cite web | archive-url = https://www.webcitation.org/5c8jC0dFt?url=http://www.mit.edu/~montfort/Varicella.pdf | archive-date = 2009-11-06 | access-date = 2009-11-06 Published as {{Cite journal | archive-url = https://web.archive.org/web/20071013191103/http://msstate.edu/Fineart_Online/Backissues/Vol_17/faf_v17_n08/reviews/montfort.html | archive-date = 2007-10-13
  • Galatea, by Emily Short (2000). Galatea is focused entirely on interaction with the animated statue of the same name. Galatea has one of the most complex interaction systems for a non-player character in an interactive fiction game. Adam Cadre called Galatea "the best NPC ever".{{cite web | access-date = 2007-01-04
  • Slouching Towards Bedlam, by Star C. Foster and Daniel Ravipinto (2003). Set in a steampunk setting, the game narratively integrates meta-game functionality (saving, restoring, restarting) into the game world itself. The game won two XYZZY Awards and received the highest average score of any game in the Interactive Fiction Competition as of 2006.

Inform 7

On April 30, 2006, Graham Nelson announced the beta release of Inform 7 to the rec.arts.int-fiction newsgroup.{{cite newsgroup | message-id = 1146419288.944486.157150@i39g2000cwa.googlegroups.com | access-date = 2007-01-04

, Inform 7 and its and tools remain under development.{{cite newsgroup |message-id = 1169164007.311210.64650@a75g2000cwd.googlegroups.com |access-date = 2007-03-30 Also archived at |author2-link = Graham Nelson |author-link = Emily Short |access-date = March 31, 2007 |archive-url = https://web.archive.org/web/20080905103637/http://www.inform-fiction.org/I7Downloads/Documents/January2007Document.txt |archive-date = September 5, 2008 |url-status = dead

Inform 7 was named Natural Inform for a brief period of time, but was later renamed Inform 7. This old name is why the Inform 7 compiler is named "NI".{{cite newsgroup | message-id = 1175250734.801804.199340@y80g2000hsf.googlegroups.com | access-date = 2007-03-30

Inform 7 IDE

Inform 7 comes with an integrated development environment (IDE) for Mac OS X, Microsoft Windows and Linux. The Mac OS X IDE was developed by Andrew Hunter. The Microsoft Windows IDE was developed by David Kinder. The Linux IDE (known as GNOME Inform) was developed by Philip Chimento.{{cite web

The Inform 7 IDE includes a text editor for editing Inform 7 source code. Like many other programming editors it features syntax highlighting. It marks quoted strings in one color. Headings of organizational sections (Volumes, Books, Chapters, Parts, and Sections) are bolded and made larger. Comments are set in a different color and made slightly smaller.

The IDE includes a built-in Z-code interpreter. The Mac OS X IDE's interpreter is based on the Zoom interpreter by Andrew Hunter, with contributions from Jesse McGrew. The Microsoft Windows IDE's interpreter is based on WinFrotz.

As a developer tests the game in the built-in interpreter, progress is tracked in the "skein" and "transcript" views of the IDE. The skein tracks player commands as a tree of branching possibilities. Any branch of the tree can be quickly re-followed, making it possible to retry different paths in a game under development without replaying the same portions of the game. Paths can also be annotated with notes and marked as solutions, which can be exported as text walkthroughs. The transcript, on the other hand, tracks both player commands and the game's responses. Correct responses from the game can be marked as "blessed". On replaying a transcript or a branch of the skein, variations from the blessed version will be highlighted, which can help the developer find errors.

The IDE also provides various indices into the program under development. The code is shown as a class hierarchy, a traditional IF map, a book-like table of contents, and in other forms. Clicking items in the index jumps to the relevant source code.

The IDE presents two side-by-side panes for working in. Each pane can contain the source code being worked on, the current status of compilation, the skein, the transcript, the indices of the source code, a running version of the game, documentation for Inform 7 or any installed extensions to it, or settings. The concept is to imitate an author's manuscript book by presenting two "facing pages" instead of a multitude of separate windows.

Inform 7 programming language

Notable features include strong bias towards declarative rule-based style of programming and ability to infer types and properties of objects from the way they are used. For example, the statement "John wears a hat." creates a "person" called "John" (since only people are capable of wearing things), creates a "thing" with the "wearable" property (since only objects marked "wearable" are capable of being worn), and sets John as wearing the hat.

Another notable aspect of the language is direct support for relations which track associations between objects. This includes automatically provided relations, like one object containing another or an object being worn, but the developer can add their own relations. A developer might add relations indicating love or hatred between beings, or to track which characters in a game have met each other.

Inform 7 is a highly domain-specific programming language, providing the writer/programmer with a much higher level of abstraction than Inform 6, and highly readable resulting source code. General-purpose logical and arithmetic statements are written in natural language (see e.g. the "Physics" example in The Inform Recipe Book).

In early Inform 7, the compiler translates the code to Inform 6, much like CFront did with C++ and C. The current compiler (as of version 10 of 2022) is additionally able to translate the code directly to C for a native executable, and to generate an "index mini-website" describing the story.

Example game

Statements in Inform 7 take the form of complete sentences. Blank lines and indentation are in some places structurally significant. The basic form of an Inform 7 program is as follows:

"Hello, World!" by "I.F. Author"

The world is a room.

When play begins, say "Hello, World!"

The following is a reimplementation of the above "Hello Deductible" example written in Inform 7. It relies on the library known as "The Standard Rules" which are automatically included in all Inform 7 compilations.

"Hello Deductible" by "I.F. Author"

The story headline is "An Interactive Example".

The Living Room is a room. "A comfortably furnished living room."
The Kitchen is north of the Living Room.
The Front Door is south of the Living Room.
The Front Door is a door. The Front Door is closed and locked.

The insurance salesman is a man in the Living Room. The description is "An insurance salesman in a tacky polyester suit. He seems eager to speak to you." Understand "man" as the insurance salesman.

A briefcase is carried by the insurance salesman. The description is "A slightly worn, black briefcase."  Understand "case" as the briefcase.

The insurance paperwork is in the briefcase. The description is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork.

Instead of listening to the insurance salesman: 
	say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.";
	move the insurance paperwork to the player.

Notable games written in Inform 7

Mystery House Possessed (2005), by Emily Short,{{cite web | access-date = 2007-01-04 | archive-date = May 4, 2006 | archive-url = https://web.archive.org/web/20060504184514/http://turbulence.org/Works/mystery/games.php | url-status = dead

On March 1, 2006, Short announced the release of three further games:{{cite newsgroup | message-id = 1141259182.610660.185360@p10g2000cwp.googlegroups.com | access-date = 2007-01-04 Bronze{{cite web | access-date = 2007-01-04 | access-date = 2007-01-04 | access-date = 2007-01-04 |access-date = 2007-01-04 |url-status = dead |archive-url = https://web.archive.org/web/20070210003932/http://inform-fiction.org/I7Downloads/Examples/bronze/ |archive-date = February 10, 2007 |access-date = 2007-01-04 |url-status = dead |archive-url = https://web.archive.org/web/20061212185900/http://inform-fiction.org/I7Downloads/Examples/dm/ |archive-date = December 12, 2006 |access-date = 2007-01-04 |url-status = dead |archive-url = https://web.archive.org/web/20070206202522/http://inform-fiction.org/I7Downloads/Examples/rota/ |archive-date = February 6, 2007

Emily Short's Floatpoint was the first Inform 7 game to take first place in the Interactive Fiction Competition.{{cite web | access-date = 2007-05-12 It also won 2006 XYZZY Awards for Best Setting and Best NPCs.{{cite web |access-date=2007-05-12 |url-status=dead |archive-url=https://web.archive.org/web/20070515062751/http://www.xyzzynews.com/2006winners.html |archive-date=May 15, 2007

References

References

  1. (April 28, 2022). "Inform 7 v10.1.0 is now open-source".
  2. (April 17, 2019). "What is ZIL anyway?".
  3. "The Inform Designer's Manual, v4, Contents".
  4. (13 January 2023). "Inform 7 Version History".
  5. "10.1. Gases".
  6. "Structure of the Inform 7 compiler".
Info: Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about Inform — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report