It’s been a long time I dived into Preform, but anyway, here’s some things about it, in no particular order, and maybe repeating what CrocMiam said or what you discovered yourself:
- Yes, you can use Preform to modify how the compiler understands the source text that it is reading.
- I did not experiment much with Preform and Inform 10.1, besides what’s known to be “safe” to use and included in a language extension. I haven’t tried to port the experimental French features (that try to fully translate the Preform into French) to Inform 10.1.
- Some Preform definitions have to be read early enough by the compiler to work, but I haven’t really found a pattern. From earliest to latest:
- Some have to be in the file
Syntax.preform
included in the language bundle. (Although if I remember correctly, there are no definition that need to be here to work on 6L38.)
- Some have to be in the main source text. That’s the case for the
if
/else
phrases on 6L38.
- Some have to be in a language extension (the ones specified by a language bundle and included by writing
(in French/Spanish/etc.)
after the story title. The French extension (there’s an Inform 10 branch along the main 6L38 branch), for instance, contains the bare necessary for a translation.
- You can also “cheat” by replacing a section of the language extension from a regular extension; it mostly works. That’s what the experimental French features (in the same repo) do.
There’s a file documenting all 6L02’s Preform definitions that ended in the French extension repo even if it was not supposed to. But I haven’t found a better home for it yet. (Maybe in the IF Archive?) Some definitions have changed in Inform 10, but unfortunately, I haven’t found an equivalent document for Inform 10. As stated in the Preform introduction:
Definitions like this one are scattered all across the Inform web, in order to keep them close to the code which relates to them.
So you have to search for them across Inform’s documentation, or infer their use by looking directly in the Syntax.preform
file, which contains every rule.
Also, I haven’t managed to make some rules work (or I misunderstood them). For example, in French on 6L38, there’s one to make it possible to write la lampe is a thing
(with “la” instead of “the” or “a”) and it will set the correct grammatical gender for the lamp. But this particular rule doesn’t exist anymore in Inform 10 and I couldn’t find its replacement.
All that to say that Preform is not well documented yet (I find it even worse than in 6L38). I just made a lot of experimentations to see how it works.
The next version of Inform will allow you to add a Syntax.preform
file in a language bundle and I suppose that will be the “official” and “safest” way to add some Preform. (I think it’s already implemented so it’s possible to try it by compiling Inform yourself.) Actually, I’m not sure if sprinkling some Preform directly in your source text instead of using a language bundle is/will be encouraged (a bit like the I6 that is encouraged to stay in kits.)
Sorry for the rambling and if I didn’t really answered your questions… I’ll help more if I can.
Just to be clear, the dire
phrases (i.e. French for “say”) are not set by the Preform shown in the previous post. It’s set by another independent Preform rule not shown, and a regular phrase created in the extension. It’s not relevant to the control structure thing.