Give me a hypothetical situation when knowledge of Inform 6 is necessary

I know this may be a bit advanced, but I was wondering if anyone could give an example of when Inform 6 would be used to enhance or alter Inform 7 code. I vaguely know that it usually has to do with the parser, but I’m looking for specific examples (even if only hypothetical). I don’t need code–though I’m not opposed to seeing some. A general description would be fine.

I ask because I’m seriously considering learning Inform 6 right now, because is seems more natural to me based on my prior programming experience. But I’m also likely to learn Inform 7 eventually, and the idea of being able to do some really advanced stuff sounds kind of intriguing.

2 Likes

Inform 7 is a built upon a large Inform 6 library, “kits” in modern (10.1) parlance. I7 provides various ways to interact with various parts of the underlying code… but no way at all to interact with a bunch of it.

There’s a bunch of behavior you’re not likely to really understand without looking at the kits’ source.

And often when you’re really stumped by why something weird is happening, the best course is to look at the I6 that the I7 compiler generated and see what it does.

2 Likes

That definitely sounds interesting and possibly even fun to figure out. Having the capability to do so would be pretty cool if it were ever needed.

Is there any situation where programming in I6 might occur, separate from altering the I7 source? Possibly with a fancy extension or something? (I haven’t looked into what it takes to program extensions yet, but I’m curious…)

2 Likes

Take a look at the “Punctuation Removal” extension by Emily Short. This comes with I7 so you can open it with the “Open Installed Extension…” menu item.

This extension uses I6 code to do a bunch of low-level array work.

I suspect you could do the same work using I7’s regular expression feature, so maybe it’s not the best example. But it’s the one I’ve looked at most recently.

2 Likes

I’ve got a concrete example. As you suspect, it is about the parser. I wanted to teach Inform 7 to be able to add new sets of pronouns, in particular modern singular they. (I’ll be posting in Non-binary Pronoun Discussion when I have significant updates; the current version is usable but under-documented.)

Inform 6 was critical to allowing the parser to (sufficiently efficiently) read new pronoun words as referring to the objects they’d been attached to. For example, if you define a new xe-xem pronoun, and then define a character to accept she-her and xe-xem, my extension needs to update parser state so that both “her” and “xem” become bound to than character when xe is mentioned. Without the extension, the word “xem” doesn’t even exist for the parser, and the format of words that it is willing to parse (under certain constraints) is only representable in I6 code (“Dictionary words” are enclosed in single quotes, which I7 does not accept as source code.).

But I wouldn’t actually recommend starting with I6; it is a much more “traditional” programming language than I7, but it’s also and old and rather grungy language by modern standards, being more like a high level machine language. It’s substantially less type-safe than even K&R-era C, and it’s memory management (as of runtime accessible to I6) is extremely impoverished, unless you’re also learning to use I7’s rather complex (and still only modestly type-safe) memory management library. (Admittedly, I’ve not gone and learnt this layer myself, so maybe it’s less arcane that I suspect.) Learning I7 may bend your brain a bit more than starting with I6, but it would be a rather more fruitful exercise; getting anything done with I6 is more work than in I7, and the Inform system actually provides fewer features accessible via I6 than via I7.

2 Likes

Here’s a very simple but very stupid one.

Inform 7 is strongly-typed and very type-safe. Inform 6 isn’t. So if you want to change the type of a value, you need to use I6 to do it.

To decide what number is (O - an object) serialized: (- {O} -).

Now you can do math on an object’s internal ID number (or pointer in Glulx), such as hashing it.

2 Likes

Text Capture is one of my favorites. I’ve used it to create my own “[text substitutions]” that aren’t otherwise possible in I7.

Actually I used Daniel’s Formatting Capture, which isn’t updated for 10.1.

1 Like

Thanks, everyone, for your responses. It’s given me a bit to think about. If anyone else has anything to add, please do!

As for why I’m choosing I6 for now…I recently spent several hours poring over source code for various I6 and I7 games that were released in the past year or two on IFDB.org. Given my experience with programming languages, I figured I’d get a better overview of the languages that way than by spending days reading manual and tutorials. I didn’t have too much trouble understanding the syntax of each, though admittedly I6 took a little more reasoning to figure out sometimes. While I’m a long way from being able to program successfully in either language, I feel I got enough of a grasp on the basics to judge what each one is capable of. In the end, the programming nerd in me just thought Inform 6 looked like more fun. I’m weird that way, I guess. :slight_smile:

2 Likes

You will find many examples of this on the forum. I am not an Inform 7 user, but the examples I’ve seen seem to be addressing shortcomings in Inform 7. Inform 7 does many things very well, but as soon as you find a limitation that is difficult or impossible to work around, you need to fall back to Inform 6.

You’re asking these questions in the Inform 7 category, so you’re going to get Inform 7 biased answers. For me personally, I’ve started to use Inform 7 a few times and I just don’t get it. I’m sure it’s just a case of perseverence, but I don’t have the patience. I’m comfortable with a conventional programming language and I don’t see the need to struggle with something with a downright weird syntax.

If you want to use Inform 6, just learn Inform 6. It’s not that hard, especially if you have a programming background.

PunyInform is a more light-weight version of the Inform 6 library. It is very popular. I now write all my games in PunyInform and have no regrets, except that it doesn’t have Glulx support, so I can’t do sound and graphics. As a bonus, your games are a fraction of the size of an Inform 7 game, run much faster and run on many more platforms. It is impossible to run an Inform 7 game on an 8-bit platform, but a PunyInform game revels in it.

2 Likes

If you have a conventional programming background (and are long enough in the tooth, as I am) it feels a lot like programming in BASIC vs programming in assembly language, back in the 8-bit days.

I should say that I am speaking as someone who originally learned and dabbled in I6 many years ago, without ever becoming seamlessly fluent, then recently moved on to I7 with a lot of doing bits and pieces in I6.

Back in 8-bit days, the most common reason for using assembly language was that BASIC was too slow for many purposes, albeit BASIC was closely integrated into most machines and an order of magnitude quicker to write and easier to use. Speed of execution isn’t really an issue with I7 unless you’re targeting VERY old hardware, in which case the greatly-increased memory requirements of I7-compiled stories make it impractical in any case. But there were also always things (usually to do with direct interactions with hardware) that BASIC just couldn’t do, and therefore assembly language or direct machine coding were required: the corollary is true with I7 vs I6- which of course is very close to C rather than assembly language in both aesthetic and syntax, but the analogy largely holds.

As you’re probably already aware, I7 is compiled to I6, so by definition you can do everything in I6 that you can do in I7- just as you can do everything in assembly language that you can do in BASIC. But some of the very neat things that I7 code does almost effortlessly will be very time-consuming to separately implement and debug in I6.

The current developers of I7 make noises gently discouraging mixing of I6 and I7, with veiled threats (some inadvertently crystallised in the latest Ver 10) of restricting the possibilities of ‘hybrid coding’ in the future. Conversely, they have made little or no progress in recent years in developing I7 to enable things which currently still require I6 achieve- their not inconsiderable efforts having been directed elsewhere.

As has been mentioned elsewhere, looking at and modifying the I6 code compiled from I7 can be invaluable in understanding why I7 code is not behaving as expected- although this is chiefly as a means to working out whether the observed behaviour is an error in documentation, compilation or I7’s underlying I6 code base and libraries. It does also offer the means to apply I6 patches to bend that misbehaviour to your will. You will find numerous examples on this forum if you search for ‘bug’.

My suggestion would be to learn I6 first- I think you will likely enjoy your I7 experience more if you do. But then give I7 a go and see whether you like it. If you do, your I6 skills will be far from wasted.

The aesthetic and mindset of coding in I7 and I6 are chalk and cheese and you will find yourself naturally gravitating to one or the other, but they are so different you probably have to develop a full project in each to come to a conclusion. I can reassure you that they are both fun!

6 Likes