Disabling G for again in Inform 6G

I want to remove 'oops' addresses how to disable the parser processing ‘oops’. It also makes it pretty clear (unless I’m flaking badly) I can change

Constant AGAIN2__WD     = 'g//';

to

Constant AGAIN2__WD     = 'again//';

In Language.i6t and then “g” will not run the same command again.

That’s a good solution for my current project, but I won’t always want to disable “g” as it is useful in testing some other projects I have in maintenance.

I know we can use the following syntax to replace functions:

Include (-
Replace LanguageVerb;
-) after “Definitions.i6t”.

Include (-
Replace LanguageVerb;
-) after "Definitions.i6t".

Include (-
[ LanguageVerb i;
	switch (i) {
	'i//','inv','inventory': print "take inventory";
	'l//':   print "look";
	'x//':   print "examine";
	'z//':   print "wait";
	'about':  print "see info about the game";
	'credit', 'credits': print "see the credits";
	'c//', 'p//', 'call', 'place': print "(P)lace or (C)all";
	default: rfalse;
	}
	rtrue;
];
-) after "Language.i6t".

Now, it looks like I could edit the parser_parse function in Parser.i6t, wiping out 3 instances of AGAIN2__WD in 800 lines of code. Not too bad, but … a bit unwieldy.

We can also

use MAX_EXPRESSION_NODES of 384.

But I tried the crude

use AGAIN2__WD of “again”.

And apparently Inform doesn’t like this language construction for strings.

Is there a simple way in I7 to redefine a string constant or eliminate a definition of a string constant? I’m using 6g60, but I’d be glad to move up a version for the current project to deal with this if there’s an easier way to get this done in later versions. Thanks!

2 Likes

How about:

Include (-

    #Undef AGAIN2__WD;
    Constant AGAIN2__WD = 'again';

-) after "Language.i6t".

You may need a newer version of the I6 compiler for this to work (but still an I7 version of the I6 compiler, e.g. 6M62’s Inform 6.33N which is what I used for testing).

1 Like

You can do

Include (-
! all string definitions except the one you want to drop
-) instead of "Vocabulary" in "Language.i6t".

Paste in the “Vocabulary” section there and make changes.

1 Like

Thanks so much!

I feel like I could’ve guessed UNDEF if I’d really put my thinking cap on. Inform uses constructs from other languages very well. It’s helped me learn inform and, on occasion, other languages back, too.

This idea will almost certainly come in handy for later.

For others’ reference, #Undef worked okay with 6.33, but it failed with 6.32.

FYI – a wrinkle that can affect this type of approach: See Compiler ignoring redefinition of constants in some circumstances?

Short version: #Undef doesn’t apply globally, so any routines occurring earlier in the source code than the #Undef will still make use of the original definition of the constant.

It doesn’t seem to cause a problem in this instance, because the constant’s definition and redefinition occur prior to any code that uses the constant, but it could cause a tricky-to-identify problem for anyone trying similar tricks for other constants.

3 Likes

If you want to use Undef like this, do it right after the definition section, before the constant is used.

2 Likes

I just found another case where unexpected conflicts cropped up. In the 110717 version of Erik Temple’s Undo Output Control, there’s the ability to change the words for undo and oops. However, this rewrites the part in parser.i6t which looks at the extension’s defined “oops word 1” instead of OOPS1__WD.

This was a really neat feature before the 6.3.3 compiler, but Erik couldn’t see into the future, and so it’s superseded by the #Undef code, which is easier and more general. I had to edit the inform 6 code in the extension. So people who have trouble with #Undef in a complex project may also want to look at if there is a code conflict in extensions.

Does anybody have a suggestion how to do this in kit-based Inform 7 version 10.1.2, from 2022 onwards? That is, overwrite or undef those constants?

I think it would be:

Include (-

Constant AGAIN2__WD = 'again';

-) replacing "AGAIN2__WD".
4 Likes

Makes sense, and works, thank you very much!