Question on Using "Variable Translates Into I6"

Greetings all. This is more just a question of understanding what’s going on and why. Consider the following:

seconds is a number that varies.
seconds is 0.
The seconds variable translates into I6 as "seconds".

If you do that, you get a compilation error.

The way to fix this is as follows:

seconds is a number that varies.

Include (-
Global seconds = 0;
-)

The seconds variable translates into I6 as "seconds".

What I don’t understand is why that’s needed. Meaning, why does the initial variable have to be defined in the kit? And, even with the fix I just applied, that’s not really what I’m doing anyway, right? I’m not defining anything in a kit; it’s still in my source. Unless the I6 inclusion means “this goes in a kit.” But if that’s the case, it’s very opaque.

Yet, regarding that opacity, someone may ask why even do the variable translation part in the first place. If you just didn’t do that, you could do simply this:

seconds is a number that varies.
seconds is 0.

Which is very true! So what is the value of translating the variable? I do see the example “Blink” in the manual and I suppose that’s attempting to clarify a particular type of usage but the overall rationale escapes me.

The intent of this feature is to take an already-existing I6 variable and expose it at the I7 level.

The I6 kit code (it was called “templates” in earlier version of Inform, but it’s “kits” now) defines a lot of machinery that lives entirely below the waves. I6 variables, arrays, function, etc. The “translates into I6 as” feature raises a piece of that up to the surface, so that I7 statements can refer to it.

Yes, the line “seconds is a number that varies” changes entirely in meaning. It no longer defines a new variable; it defines an I7 reference to an existing I6 variable.

And yes, this is opaque. That’s why it’s buried in the middle of the last chapter of the manual. It’s not meant for people building games; it’s meant for Graham and other people who are building the Inform system itself.

1 Like

Whether it took I6 thing and exposed it to I7 or the reverse depended on what kind it was: objects and actions would be exposed from I7 to I6, variables, properties, and rules from I6 to I7.

“translates into I6 as” is being deprecated, replaced with the clearer phrases “accessible to Inter as” and “defined by Inter as” (Inter being I7’s version of I6, which is about 98% the same, but lacks a few obscure syntax features.) With these new phrases you’ll no longer have to remember/guess which language actually defines the variable/property/etc.

2 Likes

Ah, thanks. I haven’t used this stuff much at all.

To be fair, though, it’s in the Extensions chapter for people who are building extensions as well. At the very least it’s likely someone like me would stumble across it. Case in point, this actually came up because the educators I’m working with are creating a series of extensions and going through that chapter with a fine-tooth comb. They were the ones who asked me about it, hence me playing around a bit.

The “Blink” example I referenced also comes up in chapter 2 of the Recipe Book as one of the examples of “varying what is written.”

All this said, I do take your point: it’s clearly not on the main path for those just looking to develop games but it’s also not terribly unlikely for people to run into this.

Much thanks to both of you for the clarifications and information. This definitely gives me some context.