[I7] Why do the Standard Rules sometimes use "- in to only" after embedded Inform 6 code, and do I need to use it when writing similar code?

While implementing a new action, I needed to convert some cases of a Standard Rules action to the new action. But the new action requires two nouns and the Standard Rules don’t have a “convert to” procedure for target actions requiring two nouns. So I had a look at how the Standard Rules convert to an action with one noun to see if I could adapt that to the case where the target action requires two nouns. The Standard Rules has the following code for converting to an action with one noun:

To convert to (AN - an action name) on (O - an object):
	(- return GVS_Convert({AN},{O},0); -) - in to only.

So to convert to an action with two nouns, it looks like I need to do something like this:

To convert to (AN - an action name) on (O1 - an object) and (O2 - an object):
	(- return GVS_Convert({AN},{O1},{O2}); -) - in to only.

I tried it, and it seems to work. But that “- in to only” after the embedded Inform 6 code is voodoo to me. I added it because the code that I wrote is similar to code in the Standard Rules that has it, but my code still seems to work when I remove it. Why do the Standard Rules use it? And is it something that I need to use when writing similar code?

2 Likes

It’s undocumented, so it’s not entirely clear – but from a little experimentation what it appears to be for is phrases that contain return statements (and thus ones that might terminate the current rule).

In particular, this code is accepted:

To do the thing:
	(- print 42; -).

To decide if you can do the thing:
	do the thing;
	decide no.

But substituting this causes the latter rule to be rejected, because it assumes do the thing can return in a way that isn’t valid for to decide:

To do the thing:
	(- print 42; -) - in to only.

Elsewhere in the Standard Rules the clause in to decide if only appears on some phrases that only make sense in to decide if rules, so that’s probably the opposite case.

In short, there’s probably no actual need to ever specify it on your custom rules, it’s just a bit of extra syntax sanity checking. Though again, these are just my guesses from reading this for the first time a few minutes ago, so perhaps I’m wrong. :slight_smile:

5 Likes

Although FWIW, while I haven’t tested this, you can probably accomplish the same thing as your new phrase by using the slightly more long-winded standard phrase:

convert to request of the player to perform AN with O1 and O2;

But I think it’s usually more common to just use nested actions via try instead:

try [the player] giving the harpoon to Captain Ahab instead;
3 Likes

The Standard Rules also use the formula “in to decide if only”. This seems to be a mechanism for restricting the contexts in which a phrase may be used without throwing an error. For instance, the phrase “decide no” is just defined as “return false”, but its use is permitted only in the context of “to decide if” rules.

I suspect that “in to only” really means something like “not in to decide if”. For instance, it appears in the definition of the phrase “continue the action”( which also turns out just to be “return false”). But that phrase is most likely to appear in an action rule, rather than a “to” rule. So it’s OK to use it there, but not within a “to decide if” rule (as Gavin’s example shows).

The compiler is a bit inconsistent about it.

To decide whether xyzzy:
	stop the action.

This produces an error message, which is the point. “Stop the action” compiles as the I6 line “return true”, but it’s confusing to use it this way.

Instead of jumping:
	decide yes.

This does not produce an error message, but arguably it should, “Decide yes” also compiles as “return true”, and using it this way is equally confusing.

2 Likes