Inform7/10 Reference Manual

That sounds right; when I wrote some puzzles involving giving orders to NPCs via persuasion, I had to do tons of rules about why actions failed. I copied the “Under Contract” example, which has code such as the following:

Unsuccessful attempt by Clark doing something:
	repeat through table of Clark Retorts:
		if the reason the action failed is the cause entry:
			say "[response entry][paragraph break]";
			rule succeeds;
	say "'I don't think that's in the script,' says Clark dubiously."

Table of Clark Retorts
cause	response
can't take yourself rule	"'I'm always self-possessed,' Clark remarks. You've heard that line before, but it sounds so much more convincing from him."
can't take other people rule	"'I don't think it would be appreciated if I tried to do that to [the noun],' he rumbles."
can't take component parts rule	"'I don't want to rip [the noun] out,' Clark remarks."
can't take people's possessions rule	"'I don't cotton to acting like a thief,' Clark replies. 'It ain't proper.'"

This doesn’t work, either.

lab is room.

Include (-

<control-structure-phrase> ::=
        if ... is begin |
        if ... is |
        if/unless ... |
        repeat ... |
        while ... |
        until ... |
        else/otherwise |
        else/otherwise if/unless ... |
        else/otherwise ... |
        -- otherwise |
        -- ...

<end-control-structure-phrase> ::=
        end if/unless |
        end while |
        end repeat |
        end until

-) in the Preform grammar.

To until (c - condition) begin -- end loop:
(- while (~~{c})  -).

When play begins:
let i be 1;
until i is 4 begin;
  say i;
  increment i;
end until

produces

You wrote ‘until i is 4 begin’ (source text, line 31): but this is an ‘else’ or ‘otherwise’ with no matching ‘if’ (or ‘unless’), which must be wrong.
Because of this problem, the source could not be translated into a working game. (Correct the source text to remove the difficulty and click on Go once again.)

(in the current dev version)

Some syntax, like string literals, are baked into the compiler, so that won’t change.

But all that is defined by the Preform can be totally different depending on the language. The wording, the order of the words, and so on. For example, in French, I made it possible to write adjectives after the noun in descriptions.

So yeah, the reference will only apply to those who write their source in English, but that’s the majority so it’s still useful. As far as I know, only the French translation went as far as translating the Preform, and it’s only compatible with 6L38, and doesn’t fully work, and authors aren’t even forced to use the French syntax. I find the Preform quite poorly documented.

I believe those lines in the Preform grammar are indexed by number; when Preform says “this matches the sixth pattern in <control-structure-phrase>”, the compiler says “ah, that pattern is for ‘else’, so this is an ‘else’ block”. That’s why you get that error message, because “until” is now the sixth pattern in <control-structure-phrase>.

Try putting “while/until” in the fifth line instead of adding a new one. (There’s a fancy way to mix up the ordering without confusing the compiler but I don’t understand it well enough to use it.)

2 Likes

Ha, this works. Good to know, thanks.

Include (-

<control-structure-phrase> ::=
        if ... is begin |
        if ... is |
        if/unless ... |
        repeat ... |
        while/until ... |
        else/otherwise |
        else/otherwise if/unless ... |
        else/otherwise ... |
        -- otherwise |
        -- ...

<end-control-structure-phrase> ::=
        end if/unless |
        end while/until |
        end repeat

-) in the Preform grammar.
2 Likes

Each line has an implicit label, starting with /a/. If you need to add a line (if the formulation is too complicated to be expressed as a simple slash alternative), you have to make all label explicit by adding /a/, /b/, and so on in front of each line. You can have duplicate labels, so you’d use the same letter for while and until. (Again, that’s for 6L38. It could have changed since.)

2 Likes

Ha, even this works!

[...]
<control-structure-phrase> ::= [...]
while/until/for ... | [...]

<end-control-structure-phrase> ::= [...]
       end while/until/for |
[...]

to for each/-- (i - nonexisting K variable) in (L - list of values of kind K)
  begin -- end loop:
  (- {-primitive-definition:repeat-through-list} -).

to for each/-- (loopvar - nonexisting K variable) in (OS - description of values of kind K)
  begin -- end loop:
  (- {-primitive-definition:repeat-through} -)
2 Likes

This is good stuff, and potentially very useful as a high-level quick reference similar to the “I7 Cheat Sheet.” Thank you for putting it together!

If it does get made into a standalone document, please be sure to post here with its location (and get it into the IF Archive). It would make a nice addition to the content on the I7 Resources pinned topic.

What do you mean by this?

I mean to submit it at https://ifarchive.org/.

I return with news of a completed(?) document. It can probably still use some work – there are likely some errors, and some typos, and some missing bits and pieces, and a few things that I should investigate. And I should probably scan the Preform to see if I’m missing anything else that could be mentioned. But it’s in a state where it can be used.

Read it here.

12 Likes

That’s a heroic effort. Thanks for doing it!

2 Likes

This looks really useful, and I’ll definitely refer to it in the future (it’s especially nice to have a single page I can search back and forth on easily without picking up a lot of unhelpful stuff).

Having the chunky underline on important words is a little hard to read for me:
image

It might be nice to have another option for setting apart those words. In fact, they’re already bold, so it could be nice to have a way to just switch off the underlining.

2 Likes

I wanted to distinguish “bold for emphasis” from “bold for literal text that you type in”. I’m not attached to the dashed underlines though and am open to other suggestions.

1 Like

My first thought was colored text, but that might be hard for colorblind readers (and a lot of IF authors have sight issues). I also thought of fixed-width fonts. Neither is as eye-catching as what you have, which is why I thought having the option might be nice. If no one else has any thoughts on it, you can probably leave it as it is.

Thanks again for making this!

If you’d like this to be the sort of community resource that others could edit in future, it could live on IFWiki. I think I could help you convert it to wikitext.

From memory, there’s already the beginnings of an Inform 7 tutorial but it never was finished (as the second post said, many people have started to write something like this). Found it: Inform 7 Reference Manual - IFWiki. It even has effectively the same name as your document! It’s just a table of contents so could be replaced by your document.

At the same time I can see why you’d want to retain control and copyright after devoting so much time to it.

You could use small caps for something? Maybe not text you type in, though, since people usually don’t type in caps.

1 Like

Not sure what I’d use small caps for then…

Just noting that I’m continuing to update this document as I think of other things I’d forgotten. Since posting it, I’ve made the following changes:

  • Noting that Understand rules describing or referring to only work on properties of objects.
  • Noting that table entries can use the optional word column for disambiguation.
  • Explicitly mentioning is … than and the same … as in the conditions section. Maybe they’re internally treated as special “relation verbs”, but I think they deserve special mention even if that’s the case.
  • Added an extra paragraph about comparable adjectives in the Definitions section.

It’s possible there were also other changes I forgot, but those are the ones I can remember.

If anyone else notices errors or missing bits, just let me know. I’m also considering adding links to the official manual and other resources, though that probably won’t happen anytime soon.

1 Like

Just made a few more updates, primarily in the Definitions section

  • Noted that comparable adjectives only work for objects
  • Covered the ways of defining adjectives with Inform 6
  • Added missing rather than clause to the one-line definition syntax
  • Made note of the with «response list» syntax that the Standard Rules uses when declaring Inform 6 rules, as well as translates into Inter (rather than translates into I6).