Comment by rmunn
12 hours ago
Inform 7 source code, at first glance, looks like plain English. It makes you start to wonder whether Inform 7 is actually an LLM and not a compiler. Then as you look at more code, you quickly start to see the structure of the language, and realize that it is indeed a programming language merely structured to look like English at first glance. But it's very cool that you can do things like this (example from the Inform 7 documentation):
Definition: a room is neighboring if the number of moves from it to the location is 1.
Every turn:
if a random chance of 1 in 2 succeeds:
let current location be the location of the lurking critter;
let next location be a random room which is adjacent to the current location;
if the lurking critter is visible:
say "The critter [one of]slouches[or]slithers[or]shambles[or]lurches[at random] away.";
move the lurking critter to next location;
if the lurking critter is visible:
say "A critter [one of]oozes[or]staggers[or]ambles[or]creeps[at random] into the room.";
[Whether or not the critter has moved, we need to adjust the sword-glow, because the player may have moved.]
if the lurking critter is in the location:
adjust sword-glow to glowing brightly;
otherwise if the lurking critter is in a neighboring room:
adjust sword-glow to glowing faintly;
otherwise:
adjust sword-glow to glowless.
This snippet omits the definition of "the lurking critter" (a standard NPC) and the sword (a standard object with a custom defined method called "adjust sword-glow to"), but it should give you a good idea of what Inform 7 source code looks like. (Inform 6 looked much more like a traditional programming language).
> [Whether or not the critter has moved, we need to adjust the sword-glow, because the player may have moved.]
That must be a comment, right?
In that case: "The critter [one of]slouches[or]slithers[or]shambles[or]lurches[at random] away.";
[one of] [or] [at random] are also comments?
In code, square brackets indicate comments. But inside a string literal they indicate variable interpolation or other commands.