Help needed with odd Inform restriction

Hi,

Could someone please tell me why…

repeat with item running through stuff:
		now t-list is the list of things near the item;

produces

Its suggesting that I have to use a global variable which is just odd and looks like Inform is being a bit too helpful. Am I just going about this in the wrong way?

There will br x items near the item (where x is >=0). Short of using another loop and adding to t-list (which is what I thought the list system did anyway) I’m baffled.

If “t-list” is meant to be a temporary list then you want to phrase it like this.

let t-list be a list of things near the item;

That is assuming Inform 7 has no problems with temporary lists.

Hope this helps.

That’s about it. Inform won’t let you do very much to or with “a list of things near the item”, as long as “item” is itself a temporary variable. You can say such a list, though; so code like this should compile: Every turn: repeat with item running through things: say "Things near [the item]: [list of things near the item]."

Or you could use a global variable, temporarily. (It won’t break the list if the variable’s value changes, later.)

To explain the problem: Inform doesn’t allow you to create a description (“things near the item”) that depends on a temporary variable (item). If Inform were smarter, it would realize that the description itself is only being used once and then thrown away (“list of DESC”) but it is not currently able to make that inference.

A lot of things in Inform can be solved by defining a few global junk variables and then clearing and recycling as needed, can’t they? Kludgeriffic, just like old school times! For examples’ sake…

The junktext is some text that varies. The junkobj is an object that varies.

Now reuse these variables at will in any situation where a temporary variable won’t do the trick. Just make sure to reset them to “” or nothing between reuses.

What are the other ones?

At least two other recent help threads involved temporary variables being a key element of the problem. For example you can’t use them in string substitution, which crops up a lot. Their use seems to pose a lot of obstacles, or maybe you just consider that all to be same obstacle multiple times. In any case it’s probably the most frequent problem cited since I’ve returned to reading here, thus my observation.